#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long t = 0;
  bool f = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = 1;
  for (; isdigit(c); c = getchar()) t = t * 10 + c - 48;
  return f ? -t : t;
}
const long long N = 200005;
const long long K = 600005;
struct node {
  long long l, r, v, id;
} a[N], b[N];
long long n, m, s[K], tot, ans, ansa, ansb;
struct Tree {
  long long lazy, Max;
} tree[K << 2];
bool cmp1(node x, node y) { return x.l < y.l; }
bool cmp2(node x, node y) { return x.r > y.r; }
void down(long long id) {
  if (tree[id].lazy) {
    long long x = tree[id].lazy;
    if (b[tree[id << 1].lazy].v < b[x].v) tree[id << 1].lazy = x;
    if (b[tree[id << 1].Max].v < b[x].v) tree[id << 1].Max = x;
    if (b[tree[id << 1 | 1].lazy].v < b[x].v) tree[id << 1 | 1].lazy = x;
    if (b[tree[id << 1 | 1].Max].v < b[x].v) tree[id << 1 | 1].Max = x;
    tree[id].lazy = 0;
  }
}
void update(long long id, long long l, long long r, long long ll, long long rr,
            long long x) {
  if (l == ll && r == rr) {
    if (b[tree[id].lazy].v < b[x].v) tree[id].lazy = x;
    if (b[tree[id].Max].v < b[x].v) tree[id].Max = x;
    return;
  }
  down(id);
  long long mid = (l + r) >> 1;
  if (rr <= mid)
    update(id << 1, l, mid, ll, rr, x);
  else if (ll > mid)
    update(id << 1 | 1, mid + 1, r, ll, rr, x);
  else
    update(id << 1, l, mid, ll, mid, x),
        update(id << 1 | 1, mid + 1, r, mid + 1, rr, x);
}
long long query(long long id, long long k, long long l, long long r) {
  if (l == r) return tree[id].Max;
  down(id);
  long long mid = (l + r) >> 1;
  if (k <= mid)
    return query(id << 1, k, l, mid);
  else
    return query(id << 1 | 1, k, mid + 1, r);
}
signed main() {
  n = read();
  m = read();
  for (long long i = 1; i <= n; i++) {
    a[i].id = i;
    a[i].l = read();
    s[++tot] = a[i].r = read();
  }
  for (long long i = 1; i <= m; i++) {
    s[++tot] = b[i].l = read();
    s[++tot] = b[i].r = read();
    b[i].id = i;
    b[i].v = read();
  }
  sort(s + 1, s + tot + 1);
  tot = unique(s + 1, s + tot + 1) - s - 1;
  sort(a + 1, a + n + 1, cmp2);
  sort(b + 1, b + m + 1, cmp2);
  for (long long i = 1, now = 1, Min = s[tot] + 1, k = 0; i <= m; i++) {
    for (; now <= n && a[now].r >= b[i].r; now++)
      if (a[now].l < Min) {
        Min = a[now].l;
        k = a[now].id;
      }
    if (b[i].v * (b[i].r - max(Min, b[i].l)) > ans) {
      ans = b[i].v * (b[i].r - max(Min, b[i].l));
      ansa = k;
      ansb = b[i].id;
    }
  }
  sort(a + 1, a + n + 1, cmp1);
  sort(b + 1, b + m + 1, cmp1);
  for (long long i = 1, now = 1, Max = 0, k = 0; i <= m; i++) {
    for (; now <= n && a[now].l <= b[i].l; now++)
      if (a[now].r > Max) {
        Max = a[now].r;
        k = a[now].id;
      }
    if (b[i].v * (min(Max, b[i].r) - b[i].l) > ans) {
      ans = b[i].v * (min(Max, b[i].r) - b[i].l);
      ansa = k;
      ansb = b[i].id;
    }
  }
  for (long long i = 1, now = 1, l, r; i <= n; i++) {
    for (; now <= m && b[now].l <= a[i].l; now++) {
      l = lower_bound(s + 1, s + tot + 1, b[now].l) - s;
      r = lower_bound(s + 1, s + tot + 1, b[now].r) - s;
      update(1, 1, tot, l, r, now);
    }
    l = lower_bound(s + 1, s + tot + 1, a[i].r) - s;
    long long k = query(1, l, 1, tot);
    if (b[k].v * (a[i].r - a[i].l) > ans) {
      ans = b[k].v * (a[i].r - a[i].l);
      ansa = a[i].id;
      ansb = b[k].id;
    }
  }
  if (!ans) return puts("0"), 0;
  printf("%lld\n%lld %lld", ans, ansa, ansb);
  return 0;
}
