"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

!function () {
  var Treap = function () {
    var notInsertedError = new Error("Not Inserted");
    return (
      /*#__PURE__*/
      function () {
        function Treap(getSortKey) {
          _classCallCheck(this, Treap);

          this.getSortKey = getSortKey || function (x) {
            return x;
          };

          this.root = null;
        }

        _createClass(Treap, [{
          key: "insert",
          value: function insert(value) {
            var priority = Math.random();
            var parents = [];
            var node = {
              value: value,
              key: this.getSortKey(value),
              priority: priority,
              left: null,
              right: null
            };

            try {
              var newRoot = this._insertNode(node, this.root, parents);

              this.root = newRoot;

              this._insertRotate(parents, node);
            } catch (e) {
              if (e !== notInsertedError) throw e;
            }
          }
        }, {
          key: "erase",
          value: function erase(value) {
            var parents = [];

            var node = this._find(value, this.root, parents);

            if (null != node) this._eraseRotate(node, parents);
          }
        }, {
          key: "min",
          value: function min() {
            var root = this.root;

            for (; null != root;) {
              if (null == root.left) return root.value;
              root = root.left;
            }

            return null;
          }
        }, {
          key: "_insertNode",
          value: function _insertNode(node, target, parents) {
            if (null == target) return node;
            parents.push(target);

            if (node.key < target.key) {
              var newRoot = this._insertNode(node, target.left, parents);

              target.left = newRoot;
            } else if (node.key > target.key) {
              var _newRoot = this._insertNode(node, target.right, parents);

              target.right = _newRoot;
            } else throw notInsertedError;

            return target;
          }
        }, {
          key: "_insertRotate",
          value: function _insertRotate(parents, bottom) {
            var parent = parents.pop();

            if (null != parent) {
              if (!(parent.priority > bottom.priority)) {
                if (parent.left === bottom) {
                  var br = bottom.right;
                  bottom.right = parent;
                  parent.left = br;
                } else if (parent.right === bottom) {
                  var bl = bottom.left;
                  bottom.left = parent;
                  parent.right = bl;
                } else throw new Error("Invariant error");

                this._insertRotate(parents, bottom);
              }
            } else this.root = bottom;
          }
        }, {
          key: "_eraseRotate",
          value: function _eraseRotate(node, parents) {
            var parent = parents[parents.length - 1];

            if (null != node.left || null != node.right) {
              if (!(null == node.left || node.left.priority < node.right.priority)) {
                if (null == parent) this.root = node.left;else if (parent.left === node) parent.left = node.left;else parent.right = node.left;
                parents.push(node.left);
                var _node$left = node.left,
                    left = _node$left.left,
                    right = _node$left.right;
                node.left = left;
                node.right = right;
              } else {
                if (null == parent) this.root = node.right;else if (parent.left === node) parent.left = node.right;else parent.right = node.right;
                parents.push(node.right);
                var _node$right = node.right,
                    _left = _node$right.left,
                    _right = _node$right.right;
                node.left = _left;
                node.right = _right;
              }

              this._eraseRotate(node, parents);
            } else if (null == parent) this.root = null;else if (parent.left === node) parent.left = null;else parent.right = null;
          }
        }, {
          key: "_find",
          value: function _find(value) {
            var root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.root;
            var parents = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
            if (null == root) return null;
            if (root.value === value) return root;
            parents.push(root);
            if (value < root.value) return this._find(value, root.left, parents);else return this._find(value, root.right, parents);
          }
        }]);

        return Treap;
      }()
    );
  }();

  function splitNum(line) {
    return (Array.isArray(line) ? line : line.split(/\s+/)).map(function (n) {
      return parseInt(n);
    });
  }

  function sortByKey(arr, keys) {
    if (!Array.isArray(keys)) keys = [keys];
    return arr.sort(function (a, b) {
      var _iteratorNormalCompletion = true;
      var _didIteratorError = false;
      var _iteratorError = undefined;

      try {
        for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
          var k = _step.value;

          if ("string" == typeof k) {
            var d = a[k] - b[k];
            if (0 !== d) return d;
          } else {
            var _d = a[k[0]] - b[k[0]];

            var sig = "desc" === k[1] ? -1 : "asc" === k[1] ? 1 : Number(k[1]);
            if (0 !== _d) return _d * sig;
          }
        }
      } catch (err) {
        _didIteratorError = true;
        _iteratorError = err;
      } finally {
        try {
          if (!_iteratorNormalCompletion && _iterator.return != null) {
            _iterator.return();
          }
        } finally {
          if (_didIteratorError) {
            throw _iteratorError;
          }
        }
      }

      return 0;
    });
  }

  !function (input) {
    var lines = input.split("\n");

    var _splitNum = splitNum(lines[0]),
        _splitNum2 = _slicedToArray(_splitNum, 2),
        N = _splitNum2[0],
        Q = _splitNum2[1];

    var kouji = lines.slice(1, N + 1).map(function (line, i) {
      var _splitNum3 = splitNum(line),
          _splitNum4 = _slicedToArray(_splitNum3, 3),
          S = _splitNum4[0],
          T = _splitNum4[1],
          X = _splitNum4[2];

      return {
        i: i,
        S: S,
        T: T,
        X: X,
        startTime: S - X - .5,
        endTime: T - X - .6
      };
    });
    var D = splitNum(lines.slice(N + 1)).slice(0, Q);
    var events = [];
    var _iteratorNormalCompletion2 = true;
    var _didIteratorError2 = false;
    var _iteratorError2 = undefined;

    try {
      for (var _iterator2 = kouji[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
        var _step2$value = _step2.value,
            X = _step2$value.X,
            startTime = _step2$value.startTime,
            endTime = _step2$value.endTime;
        events.push({
          type: "add",
          time: startTime,
          X: X
        }, {
          type: "delete",
          time: endTime,
          X: X
        });
      }
    } catch (err) {
      _didIteratorError2 = true;
      _iteratorError2 = err;
    } finally {
      try {
        if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
          _iterator2.return();
        }
      } finally {
        if (_didIteratorError2) {
          throw _iteratorError2;
        }
      }
    }

    var _iteratorNormalCompletion3 = true;
    var _didIteratorError3 = false;
    var _iteratorError3 = undefined;

    try {
      for (var _iterator3 = D[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
        var d = _step3.value;
        events.push({
          type: "walker",
          time: d,
          X: 0
        });
      }
    } catch (err) {
      _didIteratorError3 = true;
      _iteratorError3 = err;
    } finally {
      try {
        if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
          _iterator3.return();
        }
      } finally {
        if (_didIteratorError3) {
          throw _iteratorError3;
        }
      }
    }

    sortByKey(events, ["time"]);
    var set = new Treap();

    for (var _i2 = 0; _i2 < events.length; _i2++) {
      var _events$_i = events[_i2],
          type = _events$_i.type,
          time = _events$_i.time,
          X = _events$_i.X;
      if ("add" === type) set.insert(X);else if ("delete" === type) set.erase(X);else {
        var stop = set.min();
        console.log(null == stop ? -1 : stop);
      }
    }
  }(require("fs").readFileSync("/dev/stdin", "utf8"));
}();
