#include <bits/stdc++.h>
using namespace std;
const long long N = 200000 + 10;
const long long M = 1000000 + 10;
const long long INF = (long long)1e9 + 10;
long long n, m;
long long tl[N], tr[N];
map<long long, long long> toX;
pair<long long, long long> a[N];
pair<pair<long long, long long>, pair<long long, int> > b[N];
long long preMax[M], sufMin[M], midMax[M];
long long queryMax(long long *c, long long p) {
  long long ret = 0;
  for (p++; p; p -= p & -p) {
    ret = max(ret, c[p]);
  }
  return ret;
}
long long queryMin(long long p) {
  long long ret = INF;
  for (p++; p; p -= p & -p) {
    ret = min(ret, sufMin[p]);
  }
  return ret;
}
void addMax(long long *c, long long p, long long value) {
  for (p++; p < M; p += p & -p) {
    c[p] = max(c[p], value);
  }
}
void addMin(long long p, long long value) {
  for (p++; p < M; p += p & -p) {
    sufMin[p] = min(sufMin[p], value);
  }
}
void solve() {
  cin >> n >> m;
  vector<long long> values;
  for (long long i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    tl[i] = x;
    tr[i] = y;
    a[i].first = x;
    a[i].second = y;
    values.push_back(a[i].first);
    values.push_back(a[i].second);
  }
  for (long long i = 0; i < m; ++i) {
    int x, y, d;
    scanf("%d%d%d", &x, &y, &d);
    b[i].first.first = x;
    b[i].first.second = y;
    b[i].second.first = d;
    b[i].second.second = i;
    values.push_back(b[i].first.first);
    values.push_back(b[i].first.second);
  }
  sort(values.begin(), values.end());
  values.erase(unique(values.begin(), values.end()), values.end());
  for (long long i = 0; i < values.size(); ++i) {
    toX[values[i]] = i;
  }
  fill(preMax, preMax + M, -1);
  fill(sufMin, sufMin + M, INF);
  fill(midMax, midMax + M, 0);
  for (long long i = 0; i < n; ++i) {
    long long l = toX[a[i].first];
    long long r = toX[a[i].second];
    addMax(preMax, l, a[i].second);
    addMin(M - r - 100, a[i].first);
  }
  sort(a, a + n);
  sort(b, b + m);
  long long ret = 0;
  long long ptr = n - 1;
  int rc = -1, rcc;
  for (long long i = m - 1; i >= 0; --i) {
    for (; ptr >= 0 && a[ptr].first >= b[i].first.first; ptr--) {
      addMax(midMax, toX[a[ptr].second], a[ptr].second - a[ptr].first);
    }
    long long maxLen = 0;
    maxLen = queryMax(midMax, toX[b[i].first.second]);
    maxLen =
        max(maxLen, queryMax(preMax, toX[b[i].first.first]) - b[i].first.first);
    maxLen = max(
        maxLen, b[i].first.second - queryMin(M - toX[b[i].first.second] - 100));
    maxLen = min(maxLen, b[i].first.second - b[i].first.first);
    if (ret < maxLen * b[i].second.first) {
      ret = maxLen * b[i].second.first;
      rc = b[i].second.second;
      rcc = i;
    }
  }
  cout << ret << endl;
  if (ret == 0) {
    return;
  }
  for (int i = 0; i < n; ++i) {
    long long nl = max(tl[i], b[rcc].first.first);
    long long nr = min(tr[i], b[rcc].first.second);
    if (nl > nr) continue;
    if ((nr - nl) * b[rcc].second.first == ret) {
      cout << i + 1 << ' ' << rc + 1 << endl;
      return;
    }
  }
}
int main() {
  solve();
  return 0;
}
