Problem: After long-term research and lots of experiments leading Megapolian automobile manufacturer «AutoVoz» released a brand new car model named «Lada Malina». One of the most impressive features of «Lada Malina» is its highly efficient environment-friendly engines.

Consider car as a point in Oxy plane. Car is equipped with k engines numbered from 1 to k. Each engine is defined by its velocity vector whose coordinates are (vxi, vyi) measured in distance units per day. An engine may be turned on at any level wi, that is a real number between  - 1 and  + 1 (inclusive) that result in a term of (wi·vxi, wi·vyi) in the final car velocity. Namely, the final car velocity is equal to 

(w1·vx1 + w2·vx2 + ... + wk·vxk, w1·vy1 + w2·vy2 + ... + wk·vyk)

Formally, if car moves with constant values of wi during the whole day then its x-coordinate will change by the first component of an expression above, and its y-coordinate will change by the second component of an expression above. For example, if all wi are equal to zero, the car won't move, and if all wi are equal to zero except w1 = 1, then car will move with the velocity of the first engine.

There are n factories in Megapolia, i-th of them is located in (fxi, fyi). On the i-th factory there are ai cars «Lada Malina» that are ready for operation.

As an attempt to increase sales of a new car, «AutoVoz» is going to hold an international exposition of cars. There are q options of exposition location and time, in the i-th of them exposition will happen in a point with coordinates (pxi, pyi) in ti days. 

Of course, at the «AutoVoz» is going to bring as much new cars from factories as possible to the place of exposition. Cars are going to be moved by enabling their engines on some certain levels, such that at the beginning of an exposition car gets exactly to the exposition location. 

However, for some of the options it may be impossible to bring cars from some of the factories to the exposition location by the moment of an exposition. Your task is to determine for each of the options of exposition location and time how many cars will be able to get there by the beginning of an exposition.

Input

The first line of input contains three integers k, n, q (2 ≤ k ≤ 10, 1 ≤ n ≤ 105, 1 ≤ q ≤ 105), the number of engines of «Lada Malina», number of factories producing «Lada Malina» and number of options of an exposition time and location respectively.

The following k lines contain the descriptions of «Lada Malina» engines. The i-th of them contains two integers vxi, vyi ( - 1000 ≤ vxi, vyi ≤ 1000) defining the velocity vector of the i-th engine. Velocity vector can't be zero, i.e. at least one of vxi and vyi is not equal to zero. It is guaranteed that no two velosity vectors are collinear (parallel).

Next n lines contain the descriptions of factories. The i-th of them contains two integers fxi, fyi, ai ( - 109 ≤ fxi, fyi ≤ 109, 1 ≤ ai ≤ 109) defining the coordinates of the i-th factory location and the number of cars that are located there.

The following q lines contain the descriptions of the car exposition. The i-th of them contains three integers pxi, pyi, ti ( - 109 ≤ pxi, pyi ≤ 109, 1 ≤ ti ≤ 105) defining the coordinates of the exposition location and the number of days till the exposition start in the i-th option.

Output

For each possible option of the exposition output the number of cars that will be able to get to the exposition location by the moment of its beginning.

Examples

Input

2 4 1
1 1
-1 1
2 3 1
2 -2 1
-2 1 1
-2 -2 1
0 0 2


Output

3


Input

3 4 3
2 0
-1 1
-1 -2
-3 0 6
1 -2 1
-3 -7 3
3 2 2
-1 -4 1
0 4 2
6 0 1


Output

4
9
0

Note

Images describing sample tests are given below. Exposition options are denoted with crosses, factories are denoted with points. Each factory is labeled with a number of cars that it has.

First sample test explanation:

  * Car from the first factory is not able to get to the exposition location in time. 
  * Car from the second factory can get to the exposition in time if we set w1 = 0, w2 = 1. 
  * Car from the third factory can get to the exposition in time if we set <image>, <image>. 
  * Car from the fourth factory can get to the exposition in time if we set w1 = 1, w2 = 0. 

<image> <image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
struct xxx {
  int id;
  long long x;
  bool operator<(const xxx &temp) const {
    if (x == temp.x) return id > temp.id;
    return x < temp.x;
  }
};
xxx xp[220000];
int cnt_x;
const int inf = 1e9 + 9;
int xx, yy;
struct point {
  int x, y, a, id;
  long long bs;
  bool operator<(const point &temp) const {
    if (abs((y - yy) * (temp.x - xx) - (x - xx) * (temp.y - yy)) == 0)
      return abs(x - xx) + abs(y - yy) > abs(temp.x - xx) + abs(temp.y - yy);
    return (y - yy) * (temp.x - xx) - (x - xx) * (temp.y - yy) < 0;
  }
};
point v[22000], fac[101000], pt[101000], vm[1 << 11];
int k, n, num_q, x[40004], cnt, x_list[101000], cx;
long long arr[101000], ans[101000];
bool cmp(point a, point b) { return a.bs < b.bs; }
int lower_bound(int left, int right, int x) {
  int mid;
  while (left <= right) {
    mid = (left + right) >> 1;
    if (x_list[mid] <= x)
      left = mid + 1;
    else
      right = mid - 1;
  }
  return right;
}
int lowbit(int x) { return x & -x; }
int main() {
  scanf("%d%d%d", &k, &n, &num_q);
  int i, j, s, p, q, in = inf, ch, ip;
  for (i = 0; i < k; i++) {
    scanf("%d%d", &v[i].x, &v[i].y);
  }
  for (i = 0; i < (1 << k); i++) {
    vm[i].x = vm[i].y = 0;
    for (j = 0; j < k; j++) {
      if (i & (1 << j)) {
        vm[i].x += v[j].x;
        vm[i].y += v[j].y;
      } else {
        vm[i].x -= v[j].x;
        vm[i].y -= v[j].y;
      }
    }
  }
  in = inf;
  for (i = 0; i < (1 << k); i++) {
    if (in > vm[i].x) {
      in = vm[i].x;
      ch = i;
    }
  }
  swap(vm[0], vm[ch]);
  xx = vm[0].x;
  yy = vm[0].y;
  sort(vm + 1, vm + (1 << k));
  int nn = 0;
  for (i = 0; i < (1 << k); i++) {
    while (nn - 2 >= 0 &&
           (vm[nn - 1].y - vm[nn - 2].y) * (vm[i].x - vm[nn - 2].x) >=
               (vm[nn - 1].x - vm[nn - 2].x) * (vm[i].y - vm[nn - 2].y))
      nn--;
    vm[nn++] = vm[i];
  }
  k = nn;
  for (i = 0; i < nn; i++) v[i] = vm[i];
  in = inf;
  cnt = 0;
  for (i = 0; i < k; i++) x[cnt++] = v[i].x;
  sort(x, x + cnt);
  nn = 0;
  for (i = 0; i < cnt; i++) {
    if (nn == 0 || x[nn - 1] < x[i]) x[nn++] = x[i];
  }
  cnt = nn;
  for (i = 0; i < n; i++) scanf("%d%d%d", &fac[i].x, &fac[i].y, &fac[i].a);
  for (i = 0; i < num_q; i++) {
    scanf("%d%d%d", &pt[i].x, &pt[i].y, &pt[i].a);
    pt[i].id = i;
  }
  cx = 0;
  for (i = 0; i < n; i++) x_list[i] = fac[i].x;
  sort(x_list, x_list + n);
  for (i = 0; i < n; i++) {
    if (cx == 0 || x_list[cx - 1] < x_list[i]) x_list[cx++] = x_list[i];
  }
  memset(ans, 0, sizeof(ans));
  for (i = 0; i < cnt - 1; i++) {
    int id[2];
    memset(id, -1, sizeof(id));
    for (j = 0; j < k; j++) {
      if (min(v[j].x, v[(j + 1) % k].x) <= x[i] &&
          max(v[j].x, v[(j + 1) % k].x) >= x[i + 1]) {
        double mx, my[2];
        mx = 0.5 * (x[i] + x[i + 1]);
        my[0] = v[j].y + (mx - v[j].x) / (v[(j + 1) % k].x - v[j].x) *
                             (v[(j + 1) % k].y - v[j].y);
        if (id[0] < 0)
          id[0] = j;
        else {
          my[1] = v[id[0]].y + (mx - v[id[0]].x) /
                                   (v[(id[0] + 1) % k].x - v[id[0]].x) *
                                   (v[(id[0] + 1) % k].y - v[id[0]].y);
          if (my[0] < my[1]) id[0] = j;
        }
        if (id[1] < 0)
          id[1] = j;
        else {
          my[1] = v[id[1]].y + (mx - v[id[1]].x) /
                                   (v[(id[1] + 1) % k].x - v[id[1]].x) *
                                   (v[(id[1] + 1) % k].y - v[id[1]].y);
          if (my[0] > my[1]) id[1] = j;
        }
      }
    }
    int x1, y1, x2, y2;
    for (int ts = 0; ts < 2; ts++) {
      x1 = v[id[0]].x;
      y1 = v[id[0]].y;
      x2 = v[(id[0] + 1) % k].x;
      y2 = v[(id[0] + 1) % k].y;
      int flag = 1;
      if (ts == 1) {
        x1 = v[id[1]].x;
        y1 = v[id[1]].y;
        x2 = v[(id[1] + 1) % k].x;
        y2 = v[(id[1] + 1) % k].y;
        flag = -1;
      }
      if (x1 > x2) {
        swap(x1, x2);
        swap(y1, y2);
      }
      cnt_x = 0;
      for (j = 0; j < num_q; j++) {
        xp[cnt_x].id = j;
        xp[cnt_x++].x = 1LL * pt[j].y * (x2 - x1) - 1LL * pt[j].x * (y2 - y1) -
                        ts - (1LL * x2 * y1 - 1LL * x1 * y2) * pt[j].a;
      }
      for (j = 0; j < n; j++) {
        xp[cnt_x].id = j + num_q;
        xp[cnt_x++].x = 1LL * fac[j].y * (x2 - x1) - 1LL * fac[j].x * (y2 - y1);
      }
      sort(xp, xp + cnt_x);
      memset(arr, 0, sizeof(arr));
      for (j = 0; j < cnt_x; j++) {
        ip = xp[j].id;
        if (ip >= num_q) {
          for (s = lower_bound(0, cx - 1, fac[ip - num_q].x) + 1; s <= cx;
               s += lowbit(s))
            arr[s] += fac[ip - num_q].a;
        } else {
          int lx, rx;
          if (i + 1 == cnt - 1)
            lx = pt[ip].x - x[i + 1] * pt[ip].a - 1;
          else
            lx = pt[ip].x - x[i + 1] * pt[ip].a;
          rx = pt[ip].x - x[i] * pt[ip].a;
          for (s = lower_bound(0, cx - 1, rx) + 1; s > 0; s -= lowbit(s))
            ans[ip] += arr[s] * flag;
          for (s = lower_bound(0, cx - 1, lx) + 1; s > 0; s -= lowbit(s))
            ans[ip] -= arr[s] * flag;
        }
      }
    }
  }
  for (i = 0; i < num_q; i++) printf("%lld\n", ans[i]);
  return 0;
}