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;
const int N = 100005;
struct Point {
  int x, y;
  Point() { x = y = 0; }
  Point(int ix, int iy) {
    x = ix;
    y = iy;
  }
  Point operator+(Point a) { return Point(x + a.x, y + a.y); }
  Point operator-(Point a) { return Point(x - a.x, y - a.y); }
  bool operator<(const Point &a) const {
    return (x == a.x) ? (y < a.y) : (x < a.x);
  }
};
struct Event {
  int when, type, y, val, i;
  Event() { when = type = -1; }
  Event(int iwhen, int itype, int iy, int ival, int ii) {
    when = iwhen;
    type = itype;
    y = iy;
    val = ival;
    i = ii;
  }
  bool operator<(const Event &a) const {
    if (when != a.when) return when < a.when;
    if (type != a.type) return type < a.type;
    if (y != a.y) return y < a.y;
    if (val != a.val) return val < a.val;
    return i < a.i;
  }
};
inline int cross(Point b, Point a, Point c) {
  b = b - a;
  c = c - a;
  return b.x * c.y - b.y * c.x;
}
void get(int k, vector<Point> &v, vector<Point> &up, vector<Point> &dw) {
  vector<Point> a;
  for (int mask = 0; mask < (1 << k); mask++) {
    Point pt;
    for (int i = 0; i < k; i++) {
      if ((mask >> i) & 1) {
        pt = pt + v[i];
      } else {
        pt = pt - v[i];
      }
    }
    a.push_back(pt);
  }
  sort(a.begin(), a.end());
  int szu = 0, szd = 0;
  for (auto x : a) {
    while (szu >= 2 && cross(x, up[szu - 1], up[szu - 2]) >= 0) {
      up.pop_back();
      szu--;
    }
    while (szd >= 2 && cross(x, dw[szd - 1], dw[szd - 2]) <= 0) {
      dw.pop_back();
      szd--;
    }
    up.push_back(x);
    szu++;
    dw.push_back(x);
    szd++;
  }
  if (up[0].x == up[1].x) {
    reverse(up.begin(), up.end());
    up.pop_back();
    reverse(up.begin(), up.end());
  }
  if (dw[szd - 1].x == dw[szd - 2].x) {
    dw.pop_back();
  }
}
pair<Point, int> factory[N], exposition[N];
long long ans[N], f[N << 2];
inline void update(int i, int x, int n) {
  while (i <= n) {
    f[i] += x;
    i += i & (-i);
  }
}
inline long long query(int i) {
  long long ret = 0;
  while (i) {
    ret += f[i];
    i &= (i - 1);
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int k, n, q;
  cin >> k >> n >> q;
  vector<Point> v(k);
  for (auto &a : v) {
    cin >> a.x >> a.y;
  }
  for (int i = 0; i < n; i++) {
    cin >> factory[i].first.x;
    cin >> factory[i].first.y;
    cin >> factory[i].second;
  }
  for (int i = 0; i < q; i++) {
    cin >> exposition[i].first.x;
    cin >> exposition[i].first.y;
    cin >> exposition[i].second;
  }
  memset(ans, 0, sizeof(ans));
  vector<Point> up, dw;
  get(k, v, up, dw);
  for (int i = 0; i + 1 < up.size(); i++) {
    int j = i + 1;
    long long dx = up[j].x - up[i].x;
    long long dy = up[j].y - up[i].y;
    vector<long long> allx, ally;
    for (int k = 0; k < n; k++) {
      long long x = factory[k].first.x;
      long long y = factory[k].first.y;
      y = y * dx - x * dy;
      allx.push_back(x);
      ally.push_back(y);
    }
    for (int k = 0; k < q; k++) {
      long long x = exposition[k].first.x;
      long long y = exposition[k].first.y;
      long long t = exposition[k].second;
      long long x1 = x + t * up[i].x;
      if (i) x1++;
      long long x2 = x + t * up[j].x;
      long long yy = (y + t * up[i].y) * dx - (x + t * up[i].x) * dy;
      allx.push_back(x1);
      allx.push_back(x2);
      ally.push_back(yy);
    }
    sort(allx.begin(), allx.end());
    sort(ally.begin(), ally.end());
    allx.resize(unique(allx.begin(), allx.end()) - allx.begin());
    ally.resize(unique(ally.begin(), ally.end()) - ally.begin());
    vector<Event> events;
    for (int k = 0; k < n; k++) {
      long long x = factory[k].first.x;
      long long y = factory[k].first.y;
      y = y * dx - x * dy;
      x = lower_bound(allx.begin(), allx.end(), x) - allx.begin();
      x++;
      y = lower_bound(ally.begin(), ally.end(), y) - ally.begin();
      y++;
      events.push_back(Event(x, 0, y, factory[k].second, -1));
    }
    for (int k = 0; k < q; k++) {
      long long x = exposition[k].first.x;
      long long y = exposition[k].first.y;
      long long t = exposition[k].second;
      long long x1 = x + t * up[i].x;
      if (i) x1++;
      long long x2 = x + t * up[j].x;
      long long yy = (y + t * up[i].y) * dx - (x + t * up[i].x) * dy;
      x1 = lower_bound(allx.begin(), allx.end(), x1) - allx.begin();
      x1++;
      x2 = lower_bound(allx.begin(), allx.end(), x2) - allx.begin();
      x2++;
      yy = lower_bound(ally.begin(), ally.end(), yy) - ally.begin();
      yy++;
      events.push_back(Event(x1, -1, yy, -1, k));
      events.push_back(Event(x2, 1, yy, 1, k));
    }
    sort(events.begin(), events.end());
    memset(f, 0, sizeof(f));
    int sz = ally.size();
    for (auto e : events) {
      if (e.type == 0) {
        update(e.y, e.val, sz);
      } else {
        long long tmp = query(e.y);
        if (e.val == -1) tmp = -tmp;
        ans[e.i] += tmp;
      }
    }
  }
  for (int i = 0; i + 1 < dw.size(); i++) {
    int j = i + 1;
    long long dx = dw[j].x - dw[i].x;
    long long dy = dw[j].y - dw[i].y;
    vector<long long> allx, ally;
    for (int k = 0; k < n; k++) {
      long long x = factory[k].first.x;
      long long y = factory[k].first.y;
      y = y * dx - x * dy;
      allx.push_back(x);
      ally.push_back(y);
    }
    for (int k = 0; k < q; k++) {
      long long x = exposition[k].first.x;
      long long y = exposition[k].first.y;
      long long t = exposition[k].second;
      long long x1 = x + t * dw[i].x;
      if (i) x1++;
      long long x2 = x + t * dw[j].x;
      long long yy = (y + t * dw[i].y) * dx - (x + t * dw[i].x) * dy - 1;
      allx.push_back(x1);
      allx.push_back(x2);
      ally.push_back(yy);
    }
    sort(allx.begin(), allx.end());
    sort(ally.begin(), ally.end());
    allx.resize(unique(allx.begin(), allx.end()) - allx.begin());
    ally.resize(unique(ally.begin(), ally.end()) - ally.begin());
    vector<Event> events;
    for (int k = 0; k < n; k++) {
      long long x = factory[k].first.x;
      long long y = factory[k].first.y;
      y = y * dx - x * dy;
      x = lower_bound(allx.begin(), allx.end(), x) - allx.begin();
      x++;
      y = lower_bound(ally.begin(), ally.end(), y) - ally.begin();
      y++;
      events.push_back(Event(x, 0, y, factory[k].second, -1));
    }
    for (int k = 0; k < q; k++) {
      long long x = exposition[k].first.x;
      long long y = exposition[k].first.y;
      long long t = exposition[k].second;
      long long x1 = x + t * dw[i].x;
      if (i) x1++;
      long long x2 = x + t * dw[j].x;
      long long yy = (y + t * dw[i].y) * dx - (x + t * dw[i].x) * dy - 1;
      x1 = lower_bound(allx.begin(), allx.end(), x1) - allx.begin();
      x1++;
      x2 = lower_bound(allx.begin(), allx.end(), x2) - allx.begin();
      x2++;
      yy = lower_bound(ally.begin(), ally.end(), yy) - ally.begin();
      yy++;
      events.push_back(Event(x1, -1, yy, 1, k));
      events.push_back(Event(x2, 1, yy, -1, k));
    }
    sort(events.begin(), events.end());
    memset(f, 0, sizeof(f));
    int sz = ally.size();
    for (auto e : events) {
      if (e.type == 0) {
        update(e.y, e.val, sz);
      } else {
        long long tmp = query(e.y);
        if (e.val == -1) tmp = -tmp;
        ans[e.i] += tmp;
      }
    }
  }
  for (int i = 0; i < q; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}