#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}
struct MinVal {
  int x, i;
  MinVal() : x(0x3f3f3f3f), i(-1) {}
  MinVal(int x_, int i_) : x(x_), i(i_) {}
  MinVal &operator+=(const MinVal &that) {
    if (x > that.x) x = that.x, i = that.i;
    return *this;
  }
  bool operator<(const MinVal &that) const {
    return x != that.x ? x < that.x : i < that.i;
  }
};
struct FenwickTree {
  vector<MinVal> v;
  void init(int n) { v.assign(n, MinVal()); }
  void add(int i, MinVal x) {
    for (; i < (int)v.size(); i |= i + 1) v[i] += x;
  }
  MinVal sum(int i) const {
    MinVal r = MinVal();
    for (--i; i >= 0; i = (i & (i + 1)) - 1) r += v[i];
    return r;
  }
};
void twoDimensionalSumQuery(vector<pair<pair<int, int>, MinVal> > points,
                            vector<pair<pair<int, int>, int> > queries,
                            vector<MinVal> &ans) {
  int n = points.size(), m = queries.size();
  vector<int> positions;
  for (int(i) = 0; (i) < (int)(n); ++(i))
    positions.push_back(points[i].first.second);
  sort((positions).begin(), (positions).end());
  positions.erase(unique((positions).begin(), (positions).end()),
                  positions.end());
  int p = positions.size();
  FenwickTree t;
  t.init(p);
  sort((points).begin(), (points).end());
  sort((queries).begin(), (queries).end());
  int left = 0;
  for (int(i) = 0; (i) < (int)(m); ++(i)) {
    int x = queries[i].first.first;
    while (left < n && points[left].first.first < x) {
      int j = lower_bound((positions).begin(), (positions).end(),
                          points[left].first.second) -
              positions.begin();
      t.add(j, points[left].second);
      left++;
    }
    int y = lower_bound((positions).begin(), (positions).end(),
                        queries[i].first.second) -
            positions.begin();
    ans[queries[i].second] += t.sum(y);
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> l(n), r(n);
  for (int(i) = 0; (i) < (int)(n); ++(i)) scanf("%d%d", &l[i], &r[i]);
  vector<int> a(m), b(m), c(m);
  for (int(i) = 0; (i) < (int)(m); ++(i)) scanf("%d%d%d", &a[i], &b[i], &c[i]);
  vector<pair<int, int> > maxi(m, make_pair((-1), (-1)));
  vector<pair<pair<int, int>, MinVal> > points(n);
  vector<pair<pair<int, int>, int> > queries(m);
  vector<MinVal> results;
  for (int(i) = 0; (i) < (int)(n); ++(i))
    points[i] = make_pair((make_pair((-r[i]), (l[i]))), (MinVal(0, i)));
  for (int(j) = 0; (j) < (int)(m); ++(j))
    queries[j] = make_pair((make_pair((-b[j] + 1), (a[j] + 1))), (j));
  results.assign(m, MinVal());
  twoDimensionalSumQuery(points, queries, results);
  for (int(j) = 0; (j) < (int)(m); ++(j))
    if (results[j].x < 0x3f3f3f3f)
      amax(maxi[j], make_pair((b[j] - a[j]), (results[j].i)));
  for (int(i) = 0; (i) < (int)(n); ++(i))
    points[i] = make_pair((make_pair((-r[i]), (-l[i]))), (MinVal(l[i], i)));
  for (int(j) = 0; (j) < (int)(m); ++(j))
    queries[j] = make_pair((make_pair((-b[j] + 1), (-a[j]))), (j));
  results.assign(m, MinVal());
  twoDimensionalSumQuery(points, queries, results);
  for (int(j) = 0; (j) < (int)(m); ++(j))
    if (results[j].x < 0x3f3f3f3f)
      amax(maxi[j], make_pair((b[j] - results[j].x), (results[j].i)));
  for (int(i) = 0; (i) < (int)(n); ++(i))
    points[i] = make_pair((make_pair((r[i]), (l[i]))), (MinVal(-r[i], i)));
  for (int(j) = 0; (j) < (int)(m); ++(j))
    queries[j] = make_pair((make_pair((b[j]), (a[j] + 1))), (j));
  results.assign(m, MinVal());
  twoDimensionalSumQuery(points, queries, results);
  for (int(j) = 0; (j) < (int)(m); ++(j))
    if (results[j].x < 0x3f3f3f3f)
      amax(maxi[j], make_pair((-results[j].x - a[j]), (results[j].i)));
  for (int(i) = 0; (i) < (int)(n); ++(i))
    points[i] =
        make_pair((make_pair((r[i]), (-l[i]))), (MinVal(-(r[i] - l[i]), i)));
  for (int(j) = 0; (j) < (int)(m); ++(j))
    queries[j] = make_pair((make_pair((b[j]), (-a[j]))), (j));
  results.assign(m, MinVal());
  twoDimensionalSumQuery(points, queries, results);
  for (int(j) = 0; (j) < (int)(m); ++(j))
    if (results[j].x < 0x3f3f3f3f)
      amax(maxi[j], make_pair((-results[j].x), (results[j].i)));
  pair<long long, pair<int, int> > ans(0, make_pair((-1), (-1)));
  for (int(j) = 0; (j) < (int)(m); ++(j)) {
    if (maxi[j].second != -1)
      amax(ans, make_pair(((long long)maxi[j].first * c[j]),
                          (make_pair((maxi[j].second), (j)))));
  }
  if (ans.first <= 0) {
    puts("0");
  } else {
    cout << ans.first << endl;
    cout << ans.second.first + 1 << " " << ans.second.second + 1 << endl;
  }
  return 0;
}
