#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[1 << 14], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 14, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0, f = 1;
  char c = gc();
  for (; !isdigit(c); c = gc()) {
    if (c == '-') f = -1;
    if (c == EOF) return EOF;
  }
  for (; isdigit(c); c = gc()) x = (x << 1) + (x << 3) + (c ^ 48);
  return x * f;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 | 48);
}
const long long N = 2e5 + 10, K = 6e5 + 10;
long long n, m, s[K], tot, ans, ansa, ansb;
struct node {
  long long l, r, v, id;
  node(long long _l = 0, long long _r = 0, long long _v = 0, long long _id = 0)
      : l(_l), r(_r), v(_v), id(_id) {}
} a[N], b[N];
struct tree {
  long long lazy, Max;
} tree[K << 2];
bool fdd(node x, node y) { return x.l < y.l; }
bool yyh(node x, node y) { return x.r > y.r; }
inline void up(long long id) {
  tree[id].Max = max(tree[id << 1].Max, tree[id << 1 | 1].Max);
}
inline void push(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;
  }
}
inline void change(long long id, long long l, long long r, long long L,
                   long long R, long long x) {
  if (l == L && r == R) {
    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;
  }
  push(id);
  long long mid = L + R >> 1;
  if (r <= mid)
    change(id << 1, l, r, L, mid, x);
  else if (l > mid)
    change(id << 1 | 1, l, r, mid + 1, R, x);
  else {
    change(id << 1, l, mid, L, mid, x);
    change(id << 1 | 1, mid + 1, r, mid + 1, R, x);
  }
  up(id);
}
inline long long query(long long id, long long l, long long L, long long R) {
  if (L == R) return tree[id].Max;
  push(id);
  long long mid = L + R >> 1;
  if (l <= mid)
    return query(id << 1, l, L, mid);
  else
    return query(id << 1 | 1, l, mid + 1, R);
}
int main() {
  n = read(), m = read();
  for (long long i = 1; i <= n; ++i) {
    a[i].l = read(), a[i].r = read();
    a[i].id = i;
    s[++tot] = a[i].r;
  }
  for (long long i = 1; i <= m; ++i) {
    b[i].l = read(), b[i].r = read(), b[i].v = read();
    b[i].id = i;
    s[++tot] = b[i].l, s[++tot] = b[i].r;
  }
  sort(s + 1, s + 1 + tot);
  tot = unique(s + 1, s + 1 + tot) - s - 1;
  sort(a + 1, a + 1 + n, yyh);
  sort(b + 1, b + 1 + m, yyh);
  for (long long i = 1, now = 1, Min = s[tot] + 1, k = 0; i <= m; ++i) {
    while (now <= n && a[now].r >= b[i].r) {
      if (a[now].l < Min) {
        Min = a[now].l;
        k = a[now].id;
      }
      ++now;
    }
    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 + 1 + n, fdd);
  sort(b + 1, b + 1 + m, fdd);
  for (long long i = 1, now = 1, Max = 0, k = 0; i <= m; ++i) {
    while (now <= n && a[now].l <= b[i].l) {
      if (a[now].r > Max) {
        Max = a[now].r;
        k = a[now].id;
      }
      ++now;
    }
    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) {
    while (now <= m && b[now].l <= a[i].l) {
      l = lower_bound(s + 1, s + 1 + tot, b[now].l) - s;
      r = lower_bound(s + 1, s + 1 + tot, b[now].r) - s;
      change(1, l, r, 1, tot, now);
      ++now;
    }
    l = lower_bound(s + 1, s + 1 + tot, 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;
  write(ans);
  puts("");
  write(ansa), putchar(' '), write(ansb);
  return 0;
}
