#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
pair<int, int> a[200010];
struct node {
  int first, second, c;
} b[200010];
int find(vector<int> &v, int first) {
  return lower_bound(v.begin(), v.end(), first) - v.begin();
}
struct node1 {
  int first, second, t;
  bool operator<(const node1 &a) const {
    if (first != a.first) return first < a.first;
    return t < a.t;
  }
};
bool cmp(node1 a, node1 b) {
  if (a.first != b.first) return a.first > b.first;
  return a.t < b.t;
}
bool cmp1(node1 a, node1 b) {
  if (a.second != b.second) return a.second > b.second;
  return a.t < b.t;
}
int t[200010 * 16], c[200010 * 16];
void build(int p, int l, int r) {
  t[p] = -1000000007;
  if (l == r) return;
  int m = (l + r) >> 1;
  build(p << 1, l, m);
  build(p << 1 | 1, m + 1, r);
}
void upd(int p, int l, int r, int first, int v, int w) {
  if (t[p] < v) {
    t[p] = v, c[p] = w;
  }
  if (l == r) return;
  int m = (l + r) >> 1;
  if (first <= m)
    upd(p << 1, l, m, first, v, w);
  else
    upd(p << 1 | 1, m + 1, r, first, v, w);
}
pair<int, int> query(int p, int l, int r, int first, int second) {
  if (l == first && r == second) return make_pair(t[p], c[p]);
  int m = (l + r) >> 1;
  if (second <= m) return query(p << 1, l, m, first, second);
  if (first > m) return query(p << 1 | 1, m + 1, r, first, second);
  pair<int, int> a = query(p << 1, l, m, first, m),
                 b = query(p << 1 | 1, m + 1, r, m + 1, second);
  if (a.first >= b.first) return a;
  return b;
}
long long ans[200010];
int res[200010];
int main() {
  int T, i, j, k, n, m;
  scanf("%d%d", &n, &m);
  vector<int> v;
  for (i = 0; i < n; i++) {
    scanf("%d%d", &a[i].first, &a[i].second);
    v.push_back(a[i].first), v.push_back(a[i].second);
  }
  for (i = 0; i < m; i++) {
    scanf("%d%d%d", &b[i].first, &b[i].second, &b[i].c);
    v.push_back(b[i].first), v.push_back(b[i].second);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  int M = v.size();
  vector<node1> e;
  for (i = 0; i < n; i++) {
    a[i].first = find(v, a[i].first);
    a[i].second = find(v, a[i].second);
    e.push_back((node1){a[i].first, a[i].second, i});
  }
  for (i = 0; i < m; i++) {
    b[i].first = find(v, b[i].first);
    b[i].second = find(v, b[i].second);
    e.push_back((node1){b[i].first, b[i].second, i + n});
  }
  sort(e.begin(), e.end());
  build(1, 0, M - 1);
  for (i = 0; i < e.size(); i++) {
    int ty = e[i].t;
    if (ty < n) {
      upd(1, 0, M - 1, e[i].second, v[e[i].second], ty);
    } else {
      pair<int, int> q = query(1, 0, M - 1, e[i].first, M - 1);
      j = e[i].t - n;
      if (q.first > -1000000007) {
        k = min(q.first, v[b[j].second]);
        ans[j] = 1LL * b[j].c * (k - v[b[j].first]);
        res[j] = q.second;
      }
    }
  }
  build(1, 0, M - 1);
  sort(e.begin(), e.end(), cmp);
  for (i = 0; i < e.size(); i++) {
    int ty = e[i].t;
    if (ty < n) {
      upd(1, 0, M - 1, e[i].second, v[e[i].second] - v[e[i].first], ty);
    } else {
      pair<int, int> q = query(1, 0, M - 1, e[i].first, e[i].second);
      j = e[i].t - n;
      if (q.first > -1000000007) {
        long long tt = 1LL * b[j].c * q.first;
        if (ans[j] < tt) ans[j] = tt, res[j] = q.second;
      }
    }
  }
  sort(e.begin(), e.end(), cmp1);
  build(1, 0, M - 1);
  for (i = 0; i < e.size(); i++) {
    int ty = e[i].t;
    if (ty < n) {
      upd(1, 0, M - 1, e[i].first, -v[e[i].first], ty);
    } else {
      pair<int, int> q = query(1, 0, M - 1, 0, e[i].second);
      j = e[i].t - n;
      if (q.first > -1000000007) {
        k = max(-q.first, v[b[j].first]);
        long long tt = 1LL * b[j].c * (v[b[j].second] - k);
        if (ans[j] < tt) ans[j] = tt, res[j] = q.second;
      }
    }
  }
  long long A = 0;
  pair<int, int> B;
  for (i = 0; i < m; i++) {
    if (A < ans[i]) {
      A = ans[i], B = make_pair(res[i], i);
    }
  }
  if (A == 0)
    puts("0");
  else
    printf("%I64d\n%d %d\n", A, B.first + 1, B.second + 1);
  return 0;
}
