#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
int n, m;
struct node {
  int l, r, c, idx, fr;
  long long ans;
};
bool cmpl(node x, node y) {
  if (x.l != y.l) return x.l < y.l;
  return x.r < y.r;
}
bool cmpr(node x, node y) { return x.r < y.r; }
vector<node> vec;
void fixVec() {
  sort(vec.begin(), vec.end(), cmpl);
  vector<node> out;
  out.push_back(vec[0]);
  for (int i = 1; i < vec.size(); i++) {
    while (out.size() && out.back().l == vec[i].l) out.pop_back();
    if (!out.size() || out.back().r < vec[i].r) out.push_back(vec[i]);
  }
  vec = out;
}
const int LG = 19;
int mx[N][LG];
void pre() {
  for (int i = 0; i < vec.size(); i++) mx[i][0] = i;
  for (int j = 1; 1 << j <= vec.size(); j++)
    for (int i = 0; i + (1 << j) - 1 < vec.size(); i++) {
      int a = mx[i][j - 1];
      int b = mx[i + (1 << (j - 1))][j - 1];
      if (vec[a].r - vec[a].l > vec[b].r - vec[b].l)
        mx[i][j] = a;
      else
        mx[i][j] = b;
    }
}
int RMQ(int s, int e) {
  int l = log2(e - s + 1);
  int a = mx[s][l];
  int b = mx[e - (1 << l) + 1][l];
  if (vec[a].r - vec[a].l > vec[b].r - vec[b].l) return a;
  return b;
}
node arr[N];
int main() {
  scanf("%d", &n), scanf("%d", &m);
  vec.resize(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &vec[i].l), scanf("%d", &vec[i].r), vec[i].idx = i;
  fixVec();
  pre();
  for (int i = 0; i < m; ++i) {
    scanf("%d", &arr[i].l), scanf("%d", &arr[i].r), scanf("%d", &arr[i].c);
    arr[i].ans = 0;
    arr[i].idx = i;
    int s = 0, e = vec.size() - 1, md, ql = -1, qr = -1;
    while (s <= e) {
      md = s + ((e - s) >> 1);
      if (vec[md].l >= arr[i].l)
        ql = md, e = md - 1;
      else
        s = md + 1;
    }
    s = 0, e = vec.size() - 1;
    while (s <= e) {
      md = s + ((e - s) >> 1);
      if (vec[md].r <= arr[i].r)
        qr = md, s = md + 1;
      else
        e = md - 1;
    }
    if (ql == -1 || qr == -1 || ql > qr) continue;
    int fr = RMQ(ql, qr);
    arr[i].fr = vec[fr].idx;
    arr[i].ans = 1LL * (vec[fr].r - vec[fr].l) * arr[i].c;
  }
  sort(arr, arr + m, cmpl);
  int j = 0, mx = -1;
  for (int i = 0; i < m; i++) {
    while (j < vec.size() && vec[j].l <= arr[i].l) {
      if (mx == -1 || vec[j].r > vec[mx].r) mx = j;
      j++;
    }
    if (mx != -1 && vec[mx].r > arr[i].l) {
      long long res = 1LL * (min(vec[mx].r, arr[i].r) - arr[i].l) * arr[i].c;
      if (res > arr[i].ans) arr[i].ans = res, arr[i].fr = vec[mx].idx;
    }
  }
  sort(arr, arr + m, cmpr);
  j = vec.size() - 1;
  int mn = -1;
  for (int i = m - 1; i >= 0; i--) {
    while (j >= 0 && vec[j].r >= arr[i].r) {
      if (mn == -1 || vec[j].l < vec[mn].l) mn = j;
      j--;
    }
    if (mn != -1 && vec[mn].l < arr[i].r) {
      long long res = 1LL * (arr[i].r - max(vec[mn].l, arr[i].l)) * arr[i].c;
      if (res > arr[i].ans) arr[i].ans = res, arr[i].fr = vec[mn].idx;
    }
  }
  int oi = -1, oj = -1;
  long long out = 0;
  for (int i = 0; i < m; ++i)
    if (arr[i].ans > out) out = arr[i].ans, oi = arr[i].fr, oj = arr[i].idx;
  cout << out << endl;
  if (out) cout << oi + 1 << " " << oj + 1;
}
