#include <bits/stdc++.h>
using namespace std;
struct Video {
  int l, r, id;
  bool operator<(const Video& v) const {
    return tie(l, r, id) < tie(v.l, v.r, v.id);
  }
};
struct Channel {
  int a, b, c, id;
  bool operator<(const Channel& C) const {
    return tie(a, b, c, id) < tie(C.a, C.b, C.c, C.id);
  }
};
constexpr int MAXN = 200005;
Video A[MAXN];
Channel B[MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> A[i].l >> A[i].r, A[i].id = i + 1;
  }
  sort(A, A + n);
  vector<Video> vec;
  vec.push_back(A[0]);
  for (int i = 1; i < n; ++i)
    if (A[i].r > vec.back().r) vec.push_back(A[i]);
  for (int i = 0; i < m; ++i) {
    cin >> B[i].a >> B[i].b >> B[i].c, B[i].id = i + 1;
  }
  sort(B, B + m);
  long long ans = 0, ansV = -1, ansC = -1;
  for (int i = 0, j = 0; j < m; j++) {
    while (i < vec.size() and vec[i].l < B[j].a) ++i;
    if (i) --i;
    int t = i;
    for (; t < vec.size() and vec[t].l <= B[j].b; ++t) {
      auto temp =
          (long long)B[j].c * (min(vec[t].r, B[j].b) - max(vec[t].l, B[j].a));
      if (temp > ans) ans = temp, ansV = vec[t].id, ansC = B[j].id;
    }
  }
  cout << ans << endl;
  if (ans) cout << ansV << ' ' << ansC << endl;
  return 0;
}
