#include <bits/stdc++.h>
using namespace std;
struct entry {
  int l, r, c;
  int i;
};
const int N = (2e5) + 5;
entry a[N], b[N];
int vl[N];
pair<int, int> t[N];
void update(int x, pair<int, int> y) {
  for (; x < N; x |= x + 1) t[x] = max(t[x], y);
}
pair<int, int> query(int x) {
  pair<int, int> res = pair<int, int>(0, 0);
  for (; x >= 0; x = (x & (x + 1)) - 1) res = max(res, t[x]);
  return res;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i].l, &a[i].r);
    a[i].i = i + 1;
  }
  for (int j = 0; j < m; ++j) {
    scanf("%d%d%d", &b[j].l, &b[j].r, &b[j].c);
    b[j].i = j + 1;
    vl[j] = b[j].l;
  }
  sort(vl, vl + m);
  sort(a, a + n, [](const entry& a, const entry& b) { return a.l < b.l; });
  sort(b, b + m, [](const entry& a, const entry& b) { return a.l < b.l; });
  long long res = 0;
  int bi, bj;
  for (int i = 0, j = 0, k = 0; j < m; ++j) {
    while (i < n && a[i].l <= b[j].l) {
      if (a[k].r < a[i].r) k = i;
      ++i;
    }
    if (i) {
      long long x = (long long)(min(b[j].r, a[k].r) - b[j].l) * b[j].c;
      if (res < x) {
        res = x;
        bi = a[k].i;
        bj = b[j].i;
      }
    }
  }
  sort(a, a + n, [](const entry& a, const entry& b) { return a.r > b.r; });
  sort(b, b + m, [](const entry& a, const entry& b) { return a.r > b.r; });
  for (int i = 0, j = 0, k = 0; j < m; ++j) {
    while (i < n && a[i].r >= b[j].r) {
      if (a[k].l > a[i].l) k = i;
      ++i;
    }
    if (i) {
      long long x = (long long)(b[j].r - max(b[j].l, a[k].l)) * b[j].c;
      if (res < x) {
        res = x;
        bi = a[k].i;
        bj = b[j].i;
      }
    }
  }
  for (int i = 0, j = 0; i < n; ++i) {
    while (j < m && b[j].r >= a[i].r) {
      update(lower_bound(vl, vl + m, b[j].l) - vl,
             pair<int, int>(b[j].c, b[j].i));
      ++j;
    }
    pair<int, int> p = query(upper_bound(vl, vl + m, a[i].l) - vl - 1);
    long long x = (long long)(a[i].r - a[i].l) * p.first;
    if (res < x) {
      res = x;
      bi = a[i].i;
      bj = p.second;
    }
  }
  printf("%I64d\n", res);
  if (res) {
    printf("%d %d\n", bi, bj);
  }
  return 0;
}
