#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long linf = 1e18;
const int inf = 1e9;
const int N = 1e6 + 5;
int n, m, k, way, x, y, z, p[N];
pair<int, int> a[N];
pair<pair<int, int>, int> b[N];
vector<pair<int, int> > v1[N], v2[N], e1[N], e2[N];
long long ans;
int F[6][N];
map<int, int> w, h;
int merge(int w, int x, int y) { return w == 1 ? min(x, y) : max(x, y); }
void update(int w, int x, int t) {
  if (w == 2 || w == 5 || w == 4)
    for (; x < N && x > 0; x += x & -x) F[w][x] = merge(w, F[w][x], t);
  else
    for (; x > 0; x -= x & -x) F[w][x] = merge(w, F[w][x], t);
}
int query(int w, int x) {
  int ans = ((w == 1) ? inf : 0);
  if (w == 2 || w == 5 || w == 4)
    for (; x > 0; x -= x & -x) ans = merge(w, F[w][x], ans);
  else
    for (; x < N && x > 0; x += x & -x) ans = merge(w, F[w][x], ans);
  return ans;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a[i].first, &a[i].second);
    h[a[i].first] = h[a[i].second] = true;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &b[i].first.first, &b[i].first.second, &b[i].second);
    h[b[i].first.first] = h[b[i].first.second] = true;
  }
  int s = 0;
  for (__typeof(h.begin()) it = h.begin(); it != h.end(); it++) {
    w[it->first] = ++s;
    p[s] = it->first;
  }
  for (int i = 1; i <= N; i++) F[1][i] = inf;
  for (int i = 1; i <= n; i++) {
    a[i].first = w[a[i].first];
    a[i].second = w[a[i].second];
    v1[a[i].first].push_back(make_pair(a[i].second, i));
    e1[a[i].second].push_back(make_pair(a[i].first, i));
  }
  for (int i = 1; i <= m; i++) {
    b[i].first.first = w[b[i].first.first];
    b[i].first.second = w[b[i].first.second];
    v2[b[i].first.first].push_back(make_pair(b[i].first.second, i));
    e2[b[i].first.second].push_back(make_pair(b[i].first.first, i));
  }
  long long x = 0;
  for (int i = s; i >= 1; i--) {
    for (__typeof(v1[i].begin()) it = v1[i].begin(); it != v1[i].end(); it++) {
      update(1, it->first, i);
      update(2, it->first, p[it->first] - p[i]);
    }
    for (__typeof(v2[i].begin()) it = v2[i].begin(); it != v2[i].end(); it++) {
      x = query(1, it->first + 1);
      if (x < it->first &&
          ans < (long long)(p[it->first] - p[x]) * b[it->second].second) {
        ans = (long long)(p[it->first] - p[x]) * b[it->second].second;
        way = it->second;
      }
      x = query(2, it->first);
      if (ans < x * b[it->second].second) {
        ans = x * b[it->second].second;
        way = it->second;
      }
    }
  }
  for (int i = 1; i <= s; i++) {
    for (__typeof(e1[i].begin()) it = e1[i].begin(); it != e1[i].end(); it++) {
      update(3, it->first, p[i] - p[it->first]);
      update(4, it->first, i);
    }
    for (__typeof(v1[i].begin()) it = v1[i].begin(); it != v1[i].end(); it++)
      update(5, i, it->first);
    for (__typeof(e2[i].begin()) it = e2[i].begin(); it != e2[i].end(); it++) {
      x = query(4, it->first);
      if (ans < (long long)(p[x] - p[it->first]) * b[it->second].second) {
        ans = (long long)(p[x] - p[it->first]) * b[it->second].second;
        way = it->second;
      }
      x = query(3, it->first);
      if (ans < x * b[it->second].second) {
        ans = x * b[it->second].second;
        way = it->second;
      }
      x = query(5, it->first);
      if (x >= i &&
          b[it->second].second * (long long)(p[i] - p[it->first]) > ans) {
        ans = b[it->second].second * (long long)(p[i] - p[it->first]);
        way = it->second;
      }
    }
  }
  cout << ans << '\n';
  if (!ans) return 0;
  for (int i = 1; i <= n; i++)
    if ((p[min(b[way].first.second, a[i].second)] -
         (long long)p[max(a[i].first, b[way].first.first)]) *
            b[way].second ==
        ans) {
      cout << i << ' ' << way << '\n';
      return 0;
    }
  return 0;
}
