#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m, t;
struct xxx {
  int l, r, id;
} a[N], b[N];
int l[N];
long long ans;
int x, y;
bool com(xxx a, xxx b) { return (a.l < b.l || (a.l == b.l && a.r > b.r)); }
inline long long read() {
  long long t = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') t = t * 10LL + c - 48LL, c = getchar();
  return t * f;
}
int main() {
  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, com);
  b[++t] = a[1];
  l[t] = a[1].l;
  for (int i = 2; i <= n; i++)
    if (a[i].r > b[t].r) b[++t] = a[i], l[t] = a[i].l;
  for (int i = 1; i <= m; i++) {
    int L = read(), R = read(), K = read();
    int k = lower_bound(l + 1, l + t + 1, L) - l - 1;
    if (k == 0) k = 1;
    for (; k <= t && b[k].l <= R; k++) {
      long long sum = 1LL * K * (min(R, b[k].r) - max(L, b[k].l));
      if (sum > ans) {
        ans = sum;
        x = b[k].id;
        y = i;
      }
    }
  }
  if (ans != 0)
    printf("%I64d\n%d %d", ans, x, y);
  else
    printf("0");
  return 0;
}
