#include <bits/stdc++.h>
using namespace std;
struct orzjzq {
  int l, r, id;
  orzjzq(int _l = 0, int _r = 0, int _id = 0) {
    l = _l;
    r = _r;
    id = _id;
  }
  bool operator<(const orzjzq &lzh) const {
    return l != lzh.l ? l < lzh.l : r < lzh.r;
  }
} a[200005];
long long read() {
  long long jzq = 0, lzq = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') lzq = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') jzq = jzq * 10 + ch - '0', ch = getchar();
  return jzq * lzq;
}
vector<orzjzq> ad;
int main() {
  int n, m;
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) a[i].l = read(), a[i].r = read(), a[i].id = i;
  sort(a + 1, a + n + 1);
  ad.push_back(orzjzq(-2e9, -2e9, -1));
  for (int i = 1; i <= n; i++)
    if (ad.back().r < a[i].r) ad.push_back(a[i]);
  n = ad.size();
  long long ans = 0;
  int id1 = -1, id2 = -1;
  for (int i = 1; i <= m; i++) {
    int l, r, c, pos;
    l = read();
    r = read();
    c = read();
    pos = lower_bound(ad.begin(), ad.end(), orzjzq(l, -1, -1)) - ad.begin() - 1;
    if (!pos) pos++;
    for (; pos < n && ad[pos].l <= r; pos++) {
      long long val = 1ll * c * (min(ad[pos].r, r) - max(ad[pos].l, l));
      if (val > ans) ans = val, id1 = ad[pos].id, id2 = i;
    }
  }
  if (!ans)
    puts("0");
  else
    printf("%I64d\n%d %d", ans, id1, id2);
}
