#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}
template <typename T, typename... U>
inline void read(T& x, U&... y) {
  read(x), read(y...);
}
const int N = 2e5 + 10;
int n, m, cnt;
int V[N << 1], MAXV[N << 3], ID[N << 3], ST[N], C[N];
struct Data {
  int l, r, id;
} A[N], B[N];
bool cmp(Data A, Data B) { return A.l < B.l; }
void Modify(int l, int r, int o, int pos, int v, int id) {
  if (v > MAXV[o]) MAXV[o] = v, ID[o] = id;
  if (l == r) return;
  int mid = l + r >> 1;
  if (pos <= mid)
    Modify(l, mid, o << 1, pos, v, id);
  else
    Modify(mid + 1, r, o << 1 | 1, pos, v, id);
}
int NUM, POS;
void Query(int l, int r, int o, int ql, int qr) {
  if (ql <= l && r <= qr) {
    if (MAXV[o] > NUM) NUM = MAXV[o], POS = ID[o];
    return;
  }
  int mid = l + r >> 1;
  if (ql <= mid) Query(l, mid, o << 1, ql, qr);
  if (qr > mid) Query(mid + 1, r, o << 1 | 1, ql, qr);
}
int main() {
  read(n, m);
  for (int i = 1; i <= n; ++i)
    read(A[i].l, A[i].r), A[i].id = i, V[++cnt] = A[i].r;
  for (int i = 1; i <= m; ++i)
    read(B[i].l, B[i].r, C[i]), B[i].id = i, V[++cnt] = B[i].r;
  sort(A + 1, A + n + 1, cmp);
  sort(B + 1, B + m + 1, cmp);
  sort(V + 1, V + cnt + 1);
  cnt = unique(V + 1, V + cnt + 1) - V - 1;
  int now = n;
  long long res = 0;
  pair<int, int> ANS;
  for (int i = m; i; --i) {
    while (now && A[now].l >= B[i].l) {
      Modify(1, cnt, 1, lower_bound(V + 1, V + cnt + 1, A[now].r) - V,
             A[now].r - A[now].l, A[now].id);
      --now;
    }
    NUM = 0;
    Query(1, cnt, 1, 1, lower_bound(V + 1, V + cnt + 1, B[i].r) - V);
    if (NUM) {
      long long t = 1ll * NUM * C[B[i].id];
      if (t > res) res = t, ANS = make_pair(POS, B[i].id);
    }
  }
  int top = 0;
  now = 0;
  for (int i = 1; i <= m; ++i) {
    while (now != n && A[now + 1].l <= B[i].l) {
      ++now;
      while (top && A[now].r >= A[ST[top]].r) {
        --top;
      }
      ST[++top] = now;
    }
    if (top) {
      long long t = 1ll * (min(B[i].r, A[ST[1]].r) - B[i].l) * C[B[i].id];
      if (t > res) res = t, ANS = make_pair(A[ST[1]].id, B[i].id);
    }
  }
  for (int i = 1; i <= n; ++i) swap(A[i].l, A[i].r), A[i].l *= -1, A[i].r *= -1;
  for (int i = 1; i <= m; ++i) swap(B[i].l, B[i].r), B[i].l *= -1, B[i].r *= -1;
  sort(A + 1, A + n + 1, cmp);
  sort(B + 1, B + m + 1, cmp);
  top = 0;
  now = 0;
  for (int i = 1; i <= m; ++i) {
    while (now != n && A[now + 1].l <= B[i].l) {
      ++now;
      while (top && A[now].r >= A[ST[top]].r) --top;
      ST[++top] = now;
    }
    if (top) {
      long long t = 1ll * (min(B[i].r, A[ST[1]].r) - B[i].l) * C[B[i].id];
      if (t > res) res = t, ANS = make_pair(A[ST[1]].id, B[i].id);
    }
  }
  if (res) {
    printf("%lld\n", res);
    printf("%d %d\n", ANS.first, ANS.second);
  } else
    puts("0");
  return 0;
}
