#include <bits/stdc++.h>   using namespace std;   const int maxn = 200005;   struct ppi {     long long max;     int id;     int w;   } pp1;   struct pi {     int le;     int ri;     int max;     int id;   } pp[maxn << 2];   void build(int tot, int le, int ri) {     pp[tot].le = le;     pp[tot].ri = ri;     pp[tot].max = -1000000001;     if (le == ri) return;     build(2 * tot, le, (le + ri) / 2);     build(2 * tot + 1, (le + ri) / 2 + 1, ri);   }   void merg(int tot, int p, int k, int id) {     if (pp[tot].le == pp[tot].ri) {       if (pp[tot].max < k) {         pp[tot].max = k;         pp[tot].id = id;       }       return;     }     int mid = (pp[tot].le + pp[tot].ri) / 2;     if (p <= mid) {       merg(2 * tot, p, k, id);     } else       merg(2 * tot + 1, p, k, id);     if (pp[2 * tot].max > pp[2 * tot + 1].max) {       pp[tot].max = pp[2 * tot].max;       pp[tot].id = pp[2 * tot].id;     } else {       pp[tot].max = pp[2 * tot + 1].max;       pp[tot].id = pp[2 * tot + 1].id;     }   }   ppi query(int tot, int l, int r) {     if (pp[tot].le >= l && pp[tot].ri <= r) {       pp1.max = pp[tot].max;       pp1.id = pp[tot].id;       return pp1;     }     int mid;     mid = (pp[tot].le + pp[tot].ri) / 2;     ppi pp2;     pp2.max = -1000000001;     if (l <= mid) {       pp1 = query(2 * tot, l, r);       if (pp1.max > pp2.max) {         pp2.max = pp1.max;         pp2.id = pp1.id;       }     }     if (r > mid) {       pp1 = query(2 * tot + 1, l, r);       if (pp1.max > pp2.max) {         pp2.max = pp1.max;         pp2.id = pp1.id;       }     }     return pp2;   }   struct pppi {     int l;     int r;     int c;     int id;     int ii;   } pp3[maxn], pp4[maxn], pp5[maxn << 1];   int a[maxn];   int cmp(pppi a, pppi b) {     if (a.l != b.l) return a.l < b.l;     return a.id > b.id;   }   int cmp1(pppi a, pppi b) {     if (a.r != b.r) return a.r < b.r;     return a.id < b.id;   }   int cmp2(pppi a, pppi b) {     if (a.r != b.r) return a.r < b.r;     return a.id > b.id;   }   int main() {     int i, n, m;     cin >> n >> m;     int tot = 1;     ppi pp6;     pp6.max = -10000;     for (i = 1; i <= n; i++) {       scanf( %d%d , &pp3[i].l, &pp3[i].r);       a[i] = pp3[i].r;       pp3[i].id = 1;       pp3[i].ii = i;       pp5[tot] = pp3[i];       tot++;     }     sort(a + 1, a + 1 + n);     for (i = 1; i <= m; i++) {       scanf( %d%d%d , &pp4[i].l, &pp4[i].r, &pp4[i].c);       pp4[i].id = -1;       pp4[i].ii = i;       pp5[tot] = pp4[i];       tot++;     }     tot--;     build(1, 1, n);     sort(pp5 + 1, pp5 + 1 + tot, cmp);     for (i = 1; i <= tot; i++) {       if (pp5[i].id == 1) {         int p = lower_bound(a + 1, a + 1 + n, pp5[i].r) - a;         merg(1, p, pp5[i].r, pp5[i].ii);       } else {         int p = lower_bound(a + 1, a + 1 + n, pp5[i].l) - a;         ppi pp7;         if (p >= 1 && p <= n)           pp7 = query(1, p, n);         else           pp7.max = 0;         if ((min(pp7.max, (long long)pp5[i].r) - pp5[i].l) * pp5[i].c > pp6.max) {           pp6.max = (min(pp7.max, (long long)pp5[i].r) - pp5[i].l) * pp5[i].c;           pp6.id = pp7.id;           pp6.w = pp5[i].ii;         }       }     }     for (i = 1; i <= n; i++) {       a[i] = pp3[i].l;     }     sort(a + 1, a + 1 + n);     build(1, 1, n);     sort(pp5 + 1, pp5 + tot + 1, cmp1);     for (i = tot; i >= 1; i--) {       if (pp5[i].id == 1) {         int p = lower_bound(a + 1, a + 1 + n, pp5[i].l) - a;         merg(1, p, -pp5[i].l, pp5[i].ii);       } else {         int p = lower_bound(a + 1, a + 1 + n, pp5[i].r) - a;         if (p > n) p--;         if (p >= 1 && p <= n && a[p] > pp5[i].r) p--;         ppi pp7;         if (p >= 1 && p <= n) {           pp7 = query(1, 1, p);           pp7.max = -pp7.max;           if ((pp5[i].r - max((long long)pp5[i].l, pp7.max)) * pp5[i].c >               pp6.max) {             pp6.max = (pp5[i].r - max((long long)pp5[i].l, pp7.max)) * pp5[i].c;             pp6.id = pp7.id;             pp6.w = pp5[i].ii;           }         }       }     }     sort(pp5 + 1, pp5 + 1 + n, cmp2);     build(1, 1, n);     for (i = 1; i <= tot; i++) {       if (pp5[i].id == 1) {         int p = lower_bound(a + 1, a + 1 + n, pp5[i].l) - a;         merg(1, p, pp5[i].r - pp5[i].l, pp5[i].ii);       } else {         int p = lower_bound(a + 1, a + 1 + n, pp5[i].l) - a;         if (p >= 1 && p <= n) {           ppi pp7 = query(1, p, n);           if (pp7.max * pp5[i].c > pp6.max) {             pp6.max = pp7.max * pp5[i].c;             pp6.id = pp7.id;             pp6.w = pp5[i].ii;           }         }       }     }     if (pp6.max >= 0)       cout << pp6.max << endl;     else       cout << 0 << endl;     if (pp6.max > 0) cout << pp6.id <<     << pp6.w;   }