#include <bits/stdc++.h>
using namespace std;
template <class T>
class IntervalTreeUp {
 public:
  class Node {
   public:
    T NULL_VALUE = make_pair(0, 0);
    Node *l, *r;
    T v, u;
    Node() {
      this->u = NULL_VALUE;
      this->v = NULL_VALUE;
      this->l = nullptr;
      this->r = nullptr;
    }
    Node(T v) {
      this->u = NULL_VALUE;
      this->v = v;
      l = new Node();
      r = new Node();
    }
  };
  Node *root;
  IntervalTreeUp() {}
  IntervalTreeUp(int n) {
    _size = n;
    root = new Node();
    _build(root, 1, n);
  }
  ~IntervalTreeUp() {
    _delete(root, 1, size());
    delete root;
  }
  void update(int p, pair<int, int> v) { _update(root, 1, size(), p, v); }
  void update(int l, int r, int v) { _update(root, 1, size(), l, r, v); }
  T get(int l, int r) { return _get(root, 1, size(), l, r); }
  int size() { return _size; }

 private:
  int _size;
  T fun(T a, T b) { return max(a, b); }
  T fun_up(T a, T b) { return max(a, b); }
  void perform_up(Node *old, T up) {}
  int get_mid(int l, int r) { return l + ((r - l + 1) >> 1) - 1; }
  void _build(Node *ver, int l, int r) {
    if (l == r) {
      return;
    }
    ver->l = new Node();
    ver->r = new Node();
    int m = get_mid(l, r);
    _build(ver->l, l, m);
    _build(ver->r, m + 1, r);
    ver->v = fun(ver->l->v, ver->r->v);
  }
  void _delete(Node *ver, int l, int r) {
    if (l == r) {
      return;
    }
    int m = get_mid(l, r);
    _delete(ver->l, l, m);
    delete ver->l;
    _delete(ver->r, m + 1, r);
    delete ver->r;
  }
  void _update(Node *ver, int l, int r, int p, T v) {
    _push(ver);
    if (l == r) {
      ver->v = max(ver->v, v);
      return;
    }
    int m = get_mid(l, r);
    if (p > m) {
      _update(ver->r, m + 1, r, p, v);
    } else {
      _update(ver->l, l, m, p, v);
    }
    ver->v = fun(ver->l->v, ver->r->v);
  }
  void _update(Node *ver, int l, int r, int zl, int zr, T up) {
    _push(ver);
    if (zr < l || r < zl) {
      return;
    }
    if (zl <= l && r <= zr) {
      ver->u = fun_up(ver->u, up);
      return;
    }
    int m = get_mid(l, r);
    _update(ver->l, l, m, zl, zr, up);
    _update(ver->r, m + 1, r, zl, zr, up);
  }
  T _get(Node *ver, int l, int r, int zl, int zr) {
    _push(ver);
    if (zr < l || r < zl) {
      return make_pair(0, 0);
    }
    if (zl <= l && r <= zr) {
      return ver->v;
    }
    int m = get_mid(l, r);
    return fun(_get(ver->l, l, m, zl, zr), _get(ver->r, m + 1, r, zl, zr));
  }
  void _push(Node *ver) {
    if (ver == nullptr) {
      return;
    }
    perform_up(ver->l, ver->u);
    perform_up(ver->r, ver->u);
    ver->v = fun_up(ver->v, ver->u);
    ver->u = make_pair(0, 0);
  }
};
IntervalTreeUp<pair<int, int> > *inside, *cross;
set<pair<int, int> > open;
vector<pair<int, int> > inter, windows;
vector<long long> prices, ps;
class Event {
 public:
  int pos, type, number;
  bool operator<(const Event obj) const {
    if (pos != obj.pos) return pos < obj.pos;
    if (type != obj.type) return type < obj.type;
    return number < obj.number;
  }
};
vector<Event> events;
void solve() {
  long long ans = 0;
  long long ans1 = -1, ans2 = -1;
  int n, m;
  cin >> n;
  cin >> m;
  prices.resize(m);
  inter.resize(n);
  windows.resize(m);
  Event ev = Event();
  for (int i = 0; i < n; ++i) {
    cin >> inter[i].first >> inter[i].second;
    ps.push_back(inter[i].first);
    ps.push_back(inter[i].second);
    ev.number = i;
    ev.pos = inter[i].first;
    ev.type = 0;
    events.push_back(ev);
    ev.pos = inter[i].second;
    ev.type = 1;
    events.push_back(ev);
  }
  for (int i = 0; i < m; ++i) {
    cin >> windows[i].first >> windows[i].second >> prices[i];
    ps.push_back(windows[i].first);
    ps.push_back(windows[i].second);
    ev.number = i;
    ev.type = 2;
    ev.pos = windows[i].second;
    events.push_back(ev);
  }
  sort(ps.begin(), ps.end());
  ps.erase(unique(ps.begin(), ps.end()), ps.end());
  sort(events.begin(), events.end());
  inside = new IntervalTreeUp<pair<int, int> >(ps.size());
  cross = new IntervalTreeUp<pair<int, int> >(ps.size());
  for (auto cur : events) {
    int lval, lpos, rval;
    if (cur.type != 2) {
      lval = inter[cur.number].first;
      lpos = lower_bound(ps.begin(), ps.end(), lval) - ps.begin();
      rval = inter[cur.number].second;
    } else {
      lval = windows[cur.number].first;
      lpos = lower_bound(ps.begin(), ps.end(), lval) - ps.begin();
      rval = windows[cur.number].second;
    }
    lpos++;
    if (cur.type == 0) {
      open.insert(make_pair(lval, cur.number));
    } else if (cur.type == 1) {
      open.erase(open.find(make_pair(lval, cur.number)));
      inside->update(lpos, make_pair(rval - lval, cur.number));
      cross->update(lpos, make_pair(rval, cur.number));
    } else {
      auto max_guy = make_pair(0, 0);
      auto max_full = inside->get(lpos, ps.size());
      max_guy = max(max_guy, max_full);
      auto max_part = cross->get(1, lpos);
      max_guy = max(max_guy, make_pair(max_part.first - lval, max_part.second));
      if (open.size()) {
        auto max_open = *open.begin();
        max_guy = max(max_guy, make_pair(rval - max(lval, max_open.first),
                                         max_open.second));
      }
      if ((long long)max_guy.first * prices[cur.number] > ans) {
        ans = (long long)max_guy.first * prices[cur.number];
        ans1 = max_guy.second;
        ans2 = cur.number;
      }
    }
  }
  cout << ans << endl;
  if (ans) {
    cout << ans1 + 1 << " " << ans2 + 1 << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
