#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6;
const int sh = 1 << 19;
pair<int, int> rm[2 * sh + 10];
pair<int, int> get_rmq(int l, int r) {
  l += sh;
  r += sh;
  pair<int, int> res = rm[l];
  while (l <= r) {
    res = max(res, rm[l]);
    res = max(res, rm[r]);
    l = (l + 1) / 2;
    r = (r - 1) / 2;
  }
  return res;
}
int n, m;
int l[maxn];
vector<int> st, stl, str;
int r[maxn];
pair<int, pair<int, int> > ls[maxn];
void upd(int v, pair<int, int> first) {
  v += sh;
  rm[v] = first;
  while (v > 1) {
    v /= 2;
    rm[v] = max(rm[v * 2], rm[v * 2 + 1]);
  }
}
pair<int, int> inters(int i, int L, int R) {
  return make_pair(max(0, min(R, r[i]) - max(L, l[i])), i);
}
pair<int, int> get_ans(int L, int R) {
  int pl = upper_bound((stl).begin(), (stl).end(), L) - stl.begin() - 1;
  int pr = lower_bound((str).begin(), (str).end(), R) - str.begin();
  pl = max(pl, 0);
  pr = min(pr, (int)(str).size() - 1);
  pair<int, int> res = make_pair(0, -1);
  res = max(res, inters(st[pl], L, R));
  res = max(res, inters(st[pr], L, R));
  if (pl + 1 <= pr - 1) {
    res = max(res, get_rmq(pl + 1, pr - 1));
  }
  return res;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &l[i], &r[i]);
    ls[i] = make_pair(l[i], make_pair(-r[i], i));
  }
  sort(ls, ls + n);
  pair<int, int> mx = make_pair(-1, -1);
  for (int i = 0; i < n; i++) {
    int id = ls[i].second.second;
    if (r[id] > mx.first) {
      mx = make_pair(r[id], id);
      st.push_back(id);
      stl.push_back(l[id]);
      str.push_back(r[id]);
    }
  }
  for (int i = 0; i < (int)(st).size(); i++) {
    upd(i, make_pair(str[i] - stl[i], st[i]));
  }
  pair<long long, pair<int, int> > ans =
      make_pair((long long)0, make_pair(-1, -1));
  for (int i = 0; i < m; i++) {
    int l2, r2, c;
    scanf("%d %d %d", &l2, &r2, &c);
    pair<int, int> cur = get_ans(l2, r2);
    ans =
        max(ans, make_pair((long long)c * cur.first, make_pair(cur.second, i)));
  }
  cout << ans.first << endl;
  if (ans.first) {
    cout << ans.second.first + 1 << " " << ans.second.second + 1 << endl;
  }
  return 0;
}
