#include <bits/stdc++.h>
using namespace std;
const int maxN = 200 * 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;
pair<pair<int, int>, int> a[maxN];
bool cmp(pair<pair<int, int>, int> p, pair<pair<int, int>, int> q) {
  if (p.first.first == q.first.first) return (q.first.second < p.first.second);
  return (p.first.first < q.first.first);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie();
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    cin >> a[i].first.first >> a[i].first.second, a[i].second = i;
  sort(a, a + n, cmp);
  vector<pair<pair<int, int>, int> > fake;
  for (int i = 0; i < n; i++)
    if (fake.size() == 0 || fake.back().first.second < a[i].first.second)
      fake.push_back(a[i]);
  n = fake.size();
  for (int i = 0; i < n; i++) a[i] = fake[i];
  long long ans = 0;
  int ans1 = -1, ans2 = -1;
  for (int i = 0; i < m; i++) {
    int l, r, w;
    cin >> l >> r >> w;
    int ps = lower_bound(a, a + n, make_pair(make_pair(l, -1), -1)) - a;
    if (ps) ps--;
    while (ps < n && a[ps].first.first <= r) {
      int mini = min(r, a[ps].first.second);
      int maxi = max(l, a[ps].first.first);
      if (ans < (1LL) * (mini - maxi) * w) {
        ans = (1LL) * (mini - maxi) * w;
        ans1 = a[ps].second, ans2 = i;
      }
      ps++;
    }
  }
  cout << ans << endl;
  if (ans) cout << ans1 + 1 << ' ' << ans2 + 1 << endl;
  return 0;
}
