#include <bits/stdc++.h>
using namespace std;
const long long N = 230000;
long long n, m, ans = 0, id1 = -1, id2 = -1;
struct node {
  long long l, r, id;
  friend bool operator<(node a, node b) {
    return a.l == b.l ? a.r < b.r : a.l < b.l;
  }
} a[N];
vector<node> sxd;
signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i].l >> a[i].r;
    a[i].id = i;
  }
  sort(a + 1, a + n + 1);
  sxd.push_back((node){-0x3f3f3f3f, -0x3f3f3f3f, -1});
  for (long long i = 1; i <= n; i++)
    if (a[i].r > sxd.back().r) sxd.push_back(a[i]);
  n = sxd.size();
  for (long long i = 1; i <= m; i++) {
    long long l, r, c, pos;
    cin >> l >> r >> c;
    pos = lower_bound(sxd.begin(), sxd.end(), (node){l, -1, -1}) - sxd.begin() -
          1;
    if (!pos) pos = 1;
    for (; pos < n && sxd[pos].l <= r; pos++) {
      long long now = (min(sxd[pos].r, r) - max(sxd[pos].l, l)) * c;
      if (now > ans) {
        ans = now;
        id1 = sxd[pos].id, id2 = i;
      }
    }
  }
  if (ans == 0)
    puts("0");
  else
    cout << ans << "\n" << id1 << " " << id2;
}
