#include <bits/stdc++.h>
using namespace std;
struct fin {
  vector<int> T;
  fin(int N) { T.resize(N + 47, 0); }
  int lastone(int x) { return x & (x ^ (x - 1)); }
  void put(int pos, int val) {
    for (int i = pos + 1; i < T.size(); i += lastone(i)) T[i] = max(T[i], val);
  }
  int get(int pos) {
    int ret = 0;
    for (int i = pos + 1; i > 0; i -= lastone(i)) ret = max(ret, T[i]);
    return ret;
  }
};
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<pair<pair<int, int>, int> > A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i].first.second >> A[i].first.first;
    A[i].second = i;
  }
  vector<pair<pair<int, int>, int> > B(M);
  vector<long long> C(M);
  for (int i = 0; i < M; i++) {
    cin >> B[i].first.second >> B[i].first.first >> C[i];
    B[i].second = i;
  }
  sort(begin(A), end(A));
  sort(begin(B), end(B));
  for (int i = 0; i < N; i++) swap(A[i].first.first, A[i].first.second);
  for (int i = 0; i < M; i++) swap(B[i].first.first, B[i].first.second);
  map<int, int> mp;
  for (int i = 0; i < M; i++) mp[B[i].first.first] = mp[B[i].first.second] = 0;
  for (int i = 0; i < N; i++) mp[A[i].first.first] = mp[A[i].first.second] = 0;
  int m = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) it->second = m++;
  long long ans = 0;
  int a = 0, ansA = -1, ansB = -1;
  set<pair<int, int> > right;
  set<pair<int, int> > rightS;
  for (int i = 0; i < N; i++) {
    right.insert(make_pair(A[i].first.second, i));
    rightS.insert(make_pair(A[i].first.first, i));
  }
  fin Fin(m), Fleft(m);
  for (int i = 0; i < M; i++) {
    while (a < N && A[a].first.second <= B[i].first.second) {
      rightS.erase(make_pair(A[a].first.first, a));
      right.erase(make_pair(A[a].first.second, a));
      Fin.put(m - mp[A[a].first.first], A[a].first.second - A[a].first.first);
      Fleft.put(mp[A[a].first.first], A[a].first.second);
      a++;
    }
    long long akt = C[B[i].second] * Fin.get(m - mp[B[i].first.first]);
    if (akt > ans) {
      ans = akt;
      ansA = -1;
      ansB = i;
    }
    akt = C[B[i].second] * (Fleft.get(mp[B[i].first.first]) - B[i].first.first);
    if (akt > ans) {
      ans = akt;
      ansA = -1;
      ansB = i;
    }
    if (!rightS.empty()) {
      auto it = rightS.begin();
      akt = C[B[i].second] *
            (B[i].first.second - max(B[i].first.first, it->first));
      if (akt > ans) {
        ans = akt;
        ansA = A[it->second].second;
        ansB = B[i].second;
      }
    }
  }
  cout << ans << "\n";
  if (ans == 0) return 0;
  if (ansA == -1) {
    for (int i = 0; i < N; i++)
      if (A[i].first.second <= B[ansB].first.second) {
        long long akt =
            C[B[ansB].second] *
            (A[i].first.second - max(A[i].first.first, B[ansB].first.first));
        if (akt == ans) ansA = A[i].second;
      }
    ansB = B[ansB].second;
  }
  cout << ansA + 1 << " " << ansB + 1 << "\n";
  return 0;
}
