#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using in = int;
using pl = pair<LL, LL>;
struct FenTree {
  vector<pl> f[2];
  FenTree(int len) { f[0] = f[1] = vector<pl>(len + 1, {0, -1}); }
  void insert(int x, LL v, int i) {
    x++;
    for (in k = 0; k < (2); k++) {
      for (int j = x; j < ((in)(f[k]).size()); j += j & -j)
        f[k][j] = max(f[k][j], {v, i});
      x = ((in)(f[k]).size()) - x;
    }
  }
  pl query(int x, bool high) {
    x++;
    pl r = {0, -1};
    if (high) x = ((in)(f[high]).size()) - x;
    for (; x; x -= x & -x) r = max(r, f[high][x]);
    return r;
  }
};
struct E {
  bool isv, ins;
  int i, l, r, c;
  bool operator<(E r) const { return pl(l, !ins) < pl(r.l, !r.ins); }
};
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<E> e;
  vector<int> c[2] = {vector<int>(n, 1), vector<int>(m)};
  for (in j = 0; j < (n + m); j++) {
    int l, r, i = j < n ? j : j - n;
    int& d = c[j >= n][i];
    cin >> l >> r;
    if (j >= n) cin >> d;
    for (in ins = 0; ins < (2); ins++) e.push_back({j < n, !ins, i, l, r, d});
  }
  LL best = 0, bv = -1, bc = -1;
  sort((e).begin(), (e).end());
  map<int, int> cc;
  int max = -1;
  for (in i = 0; i < (((in)(e).size())); i++) cc[e[i].l] = cc[e[i].r] = 0;
  for (auto& x : cc) x.second = ++max;
  FenTree s[2][2] = {{FenTree(max + 1), FenTree(max + 1)},
                     {FenTree(max + 1), FenTree(max + 1)}};
  for (in i = 0; i < (((in)(e).size())); i++) {
    int x = cc[e[i].r];
    if (e[i].ins) {
      for (in k = 0; k < (2); k++)
        s[e[i].isv][k].insert(x, (k ? 1 : (LL)e[i].r) * e[i].c, e[i].i);
    } else {
      for (in k = 0; k < (2); k++) {
        pl cur = s[!e[i].isv][k].query(x, k);
        if (k)
          cur.first *= (LL)(e[i].r - e[i].l);
        else
          cur.first -= cur.first ? (LL)e[i].l * c[e[i].isv][cur.second] : 0;
        cur.first *= e[i].c;
        if (cur.first > best) {
          tie(best, bv, bc) = tie(cur.first, e[i].i, cur.second);
          if (!e[i].isv) swap(bv, bc);
        }
      }
    }
  }
  cout << best << '\n';
  if (best) cout << bv + 1 << " " << bc + 1 << '\n';
}
