#include <bits/stdc++.h>
using namespace std;
int A[252521], B[252521], L[252521], R[252521];
long long C[252521];
vector<pair<int, int> > p, q;
vector<int> x, y;
int inf = 1145141919;
int dat[262144 * 2 + 10];
int query(int a, int b, int k = 0, int l = 0, int r = 262144) {
  if (r <= a || b <= l) return -inf;
  if (a <= l && r <= b) return dat[k];
  int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
  int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
  return max(vl, vr);
}
int main() {
  int n, m, id = -1, r = 0;
  long long out = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &L[i], &R[i]);
    p.push_back(make_pair(L[i], -R[i]));
  }
  sort(p.begin(), p.end());
  for (int i = 0; i < n; i++) {
    if (-p[i].second > r) {
      q.push_back(p[i]);
      r = -p[i].second;
    }
  }
  for (int i = 0; i < q.size(); i++)
    x.push_back(q[i].first), y.push_back(-q[i].second);
  for (int i = 0; i < 262144 * 2 + 10; i++) dat[i] = -inf;
  for (int i = 0; i < q.size(); i++)
    dat[262144 - 1 + i] = -q[i].first - q[i].second;
  for (int i = 262144 - 2; i >= 0; i--)
    dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &A[i], &B[i], &C[i]);
    int lo = lower_bound(x.begin(), x.end(), A[i]) - x.begin();
    int hi = lower_bound(y.begin(), y.end(), B[i] + 1) - y.begin();
    long long ret = C[i] * query(lo, hi);
    if (lo > 0) {
      ret = max(ret, C[i] * (min(B[i], -q[lo - 1].second) - A[i]));
    }
    if (hi < q.size()) {
      ret = max(ret, C[i] * (B[i] - max(A[i], q[hi].first)));
    }
    if (out < ret) {
      out = ret;
      id = i;
    }
  }
  cout << out << endl;
  if (out > 0) {
    for (int i = 0; i < n; i++) {
      if (C[id] * (min(B[id], R[i]) - max(A[id], L[i])) == out) {
        cout << i + 1 << ' ' << id + 1 << endl;
        break;
      }
    }
  }
}
