#include <bits/stdc++.h>
using namespace std;
int n, m;
int l[200005], r[200005], xx[200005], a[200005], b[200005], c[200005];
bool func(const int& a, const int& b) {
  if (l[a] != l[b])
    return l[a] < l[b];
  else
    return r[a] > r[b];
}
struct RMQ {
  int ml;
  int seg[1 << 20];
  int num[1 << 20];
  void init(int x) {
    ml = x;
    for (int i = 0; i < 1 << 20; i++) seg[i] = -2000000000, num[i] = 0;
  }
  void update(int a, int v, int n) {
    a += (1 << 19) - 1;
    v *= ml;
    if (seg[a] < v) {
      seg[a] = v;
      num[a] = n;
    }
    while (a) {
      a = (a - 1) / 2;
      if (seg[a * 2 + 1] >= seg[a * 2 + 2])
        seg[a] = seg[a * 2 + 1], num[a] = num[a * 2 + 1];
      else
        seg[a] = seg[a * 2 + 2], num[a] = num[a * 2 + 2];
    }
  }
  pair<int, int> query(int a, int b, int k, int lb, int ub) {
    if (ub < a || b < lb) return pair<int, int>(-2000000000, 0);
    if (a <= lb && ub <= b) return pair<int, int>(seg[k], num[k]);
    pair<int, int> x = query(a, b, k * 2 + 1, lb, (lb + ub) / 2);
    pair<int, int> y = query(a, b, k * 2 + 2, (lb + ub) / 2 + 1, ub);
    if (x.first >= y.first)
      return x;
    else
      return y;
  }
} R, L, I;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
    xx[i] = i;
  }
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  sort(xx + 1, xx + n + 1, func);
  vector<int> use;
  int prev = -1;
  for (int i = 1; i <= n; i++) {
    int c = xx[i];
    if (r[c] > prev) {
      prev = r[c];
      use.push_back(c);
    }
  }
  vector<int> pos;
  vector<int> x, y;
  for (int i = 0; i < use.size(); i++) {
    pos.push_back(l[use[i]]);
    pos.push_back(r[use[i]]);
    x.push_back(l[use[i]]);
    y.push_back(r[use[i]]);
  }
  sort(pos.begin(), pos.end());
  pos.erase(unique(pos.begin(), pos.end()), pos.end());
  R.init(1);
  L.init(-1);
  I.init(1);
  for (int i = 0; i < use.size(); i++) {
    l[use[i]] = lower_bound(pos.begin(), pos.end(), l[use[i]]) - pos.begin();
    r[use[i]] = lower_bound(pos.begin(), pos.end(), r[use[i]]) - pos.begin();
    R.update(l[use[i]], r[use[i]], use[i]);
    L.update(r[use[i]], l[use[i]], use[i]);
    I.update(i, pos[r[use[i]]] - pos[l[use[i]]], use[i]);
  }
  long long ans = 0;
  int ans1, ans2;
  for (int i = 1; i <= m; i++) {
    int p = upper_bound(pos.begin(), pos.end(), a[i]) - pos.begin();
    p--;
    if (p >= 0) {
      pair<int, int> g = R.query(0, p, 0, 0, (1 << 19) - 1);
      int val = g.first, id = g.second;
      if (ans < 1LL * (min(b[i], pos[val]) - a[i]) * c[i]) {
        ans = 1LL * (min(b[i], pos[val]) - a[i]) * c[i];
        ans1 = id;
        ans2 = i;
      }
    }
    p = lower_bound(pos.begin(), pos.end(), b[i]) - pos.begin();
    if (p != pos.size()) {
      pair<int, int> g = L.query(p, pos.size() - 1, 0, 0, (1 << 19) - 1);
      int val = -g.first, id = g.second;
      if (ans < 1LL * (b[i] - max(a[i], pos[val])) * c[i]) {
        ans = 1LL * (b[i] - max(a[i], pos[val])) * c[i];
        ans1 = id;
        ans2 = i;
      }
    }
    p = upper_bound(x.begin(), x.end(), a[i]) - x.begin();
    int q = lower_bound(y.begin(), y.end(), b[i]) - y.begin();
    q--;
    if (p <= q) {
      pair<int, int> g = I.query(p, q, 0, 0, (1 << 19) - 1);
      int val = g.first, id = g.second;
      if (ans < 1LL * val * c[i]) {
        ans = 1LL * val * c[i];
        ans1 = id;
        ans2 = i;
      }
    }
  }
  cout << ans << endl;
  if (ans > 0) cout << ans1 << " " << ans2 << endl;
}
