#include <bits/stdc++.h>
using namespace std;
int z, n, m;
int tree[600007 << 2];
struct point {
  int type, v, i;
};
bool cmp(point a, point b) {
  int ai = a.i + (a.type == 1 ? -1000000009 : 0);
  int bi = b.i + (b.type == 1 ? -1000000009 : 0);
  if (a.v != b.v) return a.v < b.v;
  return ai < bi;
}
void insert(int v, int l, int r, int x, int val) {
  if (l == r) {
    tree[v] = val;
    return;
  }
  int m = (l + r) / 2;
  if (x <= m)
    insert(2 * v, l, m, x, val);
  else
    insert(2 * v + 1, m + 1, r, x, val);
  tree[v] = max(tree[2 * v], tree[2 * v + 1]);
}
int query(int v, int l, int r, int p, int q) {
  if (p <= l && r <= q) {
    return tree[v];
  }
  int ret = -1000000009;
  int m = (l + r) / 2;
  if (m >= p) ret = max(ret, query(2 * v, l, m, p, q));
  if (m + 1 <= q) ret = max(ret, query(2 * v + 1, m + 1, r, p, q));
  return ret;
}
void clear() {
  for (int i = 0; i < (int)600007 * 4; i++) tree[i] = -1000000009;
}
int vl[600007];
int vr[600007];
vector<point> points;
int tl[600007], tr[600007];
long long tc[600007];
long long res[600007];
int idtl[600007];
int idtr[600007];
int idvl[600007];
int idvr[600007];
long long cross(int i, int j) {
  int c = min(tr[i] - vl[j], vr[j] - tl[i]);
  c = min(c, vr[j] - vl[j]);
  c = min(c, tr[i] - tl[i]);
  return tc[i] * c;
}
void getid() {
  for (int i = 0; i < (int)points.size(); i++) {
    point c = points[i];
    if (c.type == 0) {
      if (c.i < 0)
        idtl[abs(c.i)] = i + 1;
      else
        idtr[c.i] = i + 1;
    } else {
      if (c.i < 0)
        idvl[abs(c.i)] = i + 1;
      else
        idvr[c.i] = i + 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> vl[i] >> vr[i];
    points.push_back({1, vl[i], -i});
    points.push_back({1, vr[i], i});
  }
  for (int i = 1; i <= m; i++) {
    cin >> tl[i] >> tr[i] >> tc[i];
    points.push_back({0, tl[i], -i});
    points.push_back({0, tr[i], i});
  }
  int oldn = n;
  n = 2 * n + 2 * m;
  sort(points.begin(), points.end(), cmp);
  getid();
  int mr = -1;
  for (int i = 0; i < (int)points.size(); i++) {
    point c = points[i];
    if (c.type == 0) {
      if (c.i < 0 && mr >= tr[abs(c.i)])
        res[abs(c.i)] = tr[abs(c.i)] - tl[abs(c.i)];
    } else {
      if (c.i < 0) mr = max(vr[abs(c.i)], mr);
    }
  }
  for (int i = 0; i < (int)points.size(); i++) {
    point c = points[i];
    if (c.type == 0) {
      if (c.i > 0) {
        assert(idtr[c.i] == i + 1);
        res[c.i] =
            max(res[c.i], (long long)query(1, 1, n, idtl[c.i], idtr[c.i]));
      }
    } else {
      if (c.i > 0) {
        insert(1, 1, n, idvl[c.i], vr[abs(c.i)] - vl[abs(c.i)]);
      }
    }
  }
  clear();
  for (int i = 0; i < (int)points.size(); i++) {
    point c = points[i];
    if (c.type == 0) {
      if (c.i < 0) {
        res[abs(c.i)] =
            max(res[abs(c.i)],
                (long long)query(1, 1, n, idtl[abs(c.i)], idtr[abs(c.i)]) -
                    tl[abs(c.i)]);
      }
    } else {
      if (c.i < 0) insert(1, 1, n, idvr[abs(c.i)], vr[abs(c.i)]);
    }
  }
  clear();
  for (int i = points.size() - 1; i >= 0; i--) {
    point c = points[i];
    if (c.type == 0) {
      if (c.i > 0) {
        res[c.i] = max(res[c.i], tr[c.i] + (long long)query(1, 1, n, idtl[c.i],
                                                            idtr[c.i]));
      }
    } else {
      if (c.i > 0) {
        insert(1, 1, n, idvl[abs(c.i)], -vl[abs(c.i)]);
      }
    }
  }
  long long ans = 0;
  int ti, vid = -1;
  for (int i = 1; i <= m; i++) {
    if (ans < res[i] * tc[i]) {
      ans = res[i] * tc[i];
      ti = i;
    }
  }
  cout << ans << endl;
  if (ans) {
    for (int j = 1; j <= oldn; j++) {
      if (ans == cross(ti, j)) vid = j;
    }
    cout << vid << " " << ti << endl;
  }
}
