Problem: Anfisa the monkey got disappointed in word processors as they aren't good enough at reflecting all the range of her emotions, that's why she decided to switch to graphics editors. Having opened the BerPaint, she saw a white rectangle W × H in size which can be painted on. First Anfisa learnt to navigate the drawing tool which is used to paint segments and quickly painted on that rectangle a certain number of black-colored segments. The resulting picture didn't seem bright enough to Anfisa, that's why she turned her attention to the "fill" tool which is used to find a point on the rectangle to paint and choose a color, after which all the area which is the same color as the point it contains, is completely painted the chosen color. Having applied the fill several times, Anfisa expressed her emotions completely and stopped painting. Your task is by the information on the painted segments and applied fills to find out for every color the total area of the areas painted this color after all the fills.

Input

The first input line has two integers W and H (3 ≤ W, H ≤ 104) — the sizes of the initially white rectangular painting area. The second line contains integer n — the number of black segments (0 ≤ n ≤ 100). On the next n lines are described the segments themselves, each of which is given by coordinates of their endpoints x1, y1, x2, y2 (0 < x1, x2 < W, 0 < y1, y2 < H). All segments have non-zero length. The next line contains preset number of fills m (0 ≤ m ≤ 100). Each of the following m lines defines the fill operation in the form of "x y color", where (x, y) are the coordinates of the chosen point (0 < x < W, 0 < y < H), and color — a line of lowercase Latin letters from 1 to 15 symbols in length, determining the color. All coordinates given in the input are integers. Initially the rectangle is "white" in color, whereas the segments are drawn "black" in color.

Output

For every color present in the final picture print on the single line the name of the color and the total area of areas painted that color with an accuracy of 10 - 6. Print the colors in any order. 

Examples

Input

4 5
6
1 1 1 3
1 3 3 3
3 3 3 1
3 1 1 1
1 3 3 1
1 1 3 3
2
2 1 red
2 2 blue


Output

blue 0.00000000
white 20.00000000


Input

5 5
5
1 1 2 2
2 2 4 2
4 2 4 4
4 4 2 4
2 4 2 2
2
3 3 black
3 3 green


Output

green 4.00000000
white 21.00000000


Input

7 4
9
1 2 2 3
2 3 3 2
3 2 2 1
2 1 1 2
3 2 4 2
4 2 5 3
5 3 6 2
6 2 5 1
5 1 4 2
2
2 2 black
2 2 red


Output

red 2.00000000
white 26.00000000

Note

Initially the black segments painted by Anfisa can also be painted a color if any of the chosen points lays on the segment. The segments have areas equal to 0. That is why if in the final picture only parts of segments is painted some color, then the area, painted the color is equal to 0.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const double pi = acos(-1.0);
const double inf = 1e200;
inline int sgn(double x) { return x < -eps ? -1 : x > eps; }
inline double sqr(double x) { return x * x; }
struct P {
  double x, y;
  P(double x = 0, double y = 0) : x(x), y(y){};
  friend bool operator==(const P& p1, const P& p2) {
    return sgn(p1.x - p2.x) == 0 && sgn(p1.y - p2.y) == 0;
  }
  friend bool operator<(const P& p1, const P& p2) {
    return sgn(p1.x - p2.x) == 0 ? sgn(p1.y - p2.y) < 0 : p1.x < p2.x;
  }
  friend bool operator>(const P& p1, const P& p2) {
    return sgn(p1.x - p2.x) == 0 ? sgn(p1.y - p2.y) > 0 : p1.x > p2.x;
  }
  friend P operator+(const P& p1, const P& p2) {
    return P(p1.x + p2.x, p1.y + p2.y);
  }
  friend P operator-(const P& p1, const P& p2) {
    return P(p1.x - p2.x, p1.y - p2.y);
  }
  friend P operator*(const P& p, double a) { return P(p.x * a, p.y * a); }
  friend P operator/(const P& p, double a) { return P(p.x / a, p.y / a); }
  friend inline double operator^(const P& p1, const P& p2) {
    return p1.x * p2.x + p1.y * p2.y;
  }
  friend inline double operator*(const P& p1, const P& p2) {
    return p1.x * p2.y - p1.y * p2.x;
  }
  friend inline double dot(const P& o, const P& a, const P& b) {
    return (a - o) ^ (b - o);
  }
  friend inline double cross(const P& o, const P& a, const P& b) {
    return (a - o) * (b - o);
  }
  friend double dist(const P& p1, const P& p2) {
    return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
  }
  friend double dist2(const P& p1, const P& p2) {
    return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y);
  }
  double len() const { return sqrt(x * x + y * y); }
  double len2() const { return x * x + y * y; }
  double angle() const {
    double t = atan2(y, x);
    return sgn(t) >= 0 ? t : t + 2 * pi;
  }
  P trunc(double l) const {
    l /= len();
    return P(x * l, y * l);
  }
  P turn_left() const { return P(-y, x); }
  P turn_right() const { return P(y, -x); }
  P rotate(double th, const P& p) const {
    double c = cos(th), s = sin(th);
    return P(c * (x - p.x) - s * (y - p.y) + p.x,
             s * (x - p.x) + c * (y - p.y) + p.y);
  }
  bool input() { return scanf("%lf %lf", &x, &y) == 2; }
  void output() const { printf("%.9lf %.9lf\n", x, y); }
};
struct line {
  P a, b;
  line() {}
  line(P a, P b) : a(a), b(b) {}
  friend double dist(const P& p, const line& l) {
    return fabs(cross(p, l.a, l.b)) / dist(l.a, l.b);
  }
  friend int intersection(line l1, line l2, P& p) {
    if (l1.a == l1.b || l2.a == l2.b) return -1;
    double c1 = (l1.b - l1.a) * (l2.b - l2.a),
           c2 = (l2.a - l1.a) * (l2.b - l2.a);
    if (sgn(c1) == 0) {
      if (sgn(c2) == 0) {
        return 2;
      } else {
        return 0;
      }
    } else {
      p = l1.a + (l1.b - l1.a) * (c2 / c1);
      return 1;
    }
  }
  friend bool sameside(const P& p1, const P& p2, const line& l) {
    return sgn(cross(p1, l.a, l.b) * cross(p2, l.a, l.b)) > 0;
  }
  void input() { a.input(), b.input(); }
};
line l[123];
P p[12323];
vector<int> to[12131];
int n, zk;
int pt(int a, int b) { return (p[a] - p[zk]).angle() > (p[b] - p[zk]).angle(); }
map<int, map<int, char> > bj;
map<P, int> id;
int pid = 0;
int fd(P px) {
  if (!id[px]) {
    p[pid] = px;
    id[px] = ++pid;
  }
  return id[px] - 1;
}
int ins(line la, line lb, P& px) {
  if (intersection(la, lb, px) != 1) return 0;
  return !(px > la.b || px > lb.b || px < la.a || px < lb.a);
}
double offset = 1e4 + 4;
int inp(P q, vector<P>& p) {
  P q2;
  int n = p.size();
  int i = 0, count;
  while (i < n)
    for (count = i = 0, q2.x = rand() + offset, q2.y = rand() + offset; i < n;
         i++)
      if (!sgn(cross(q, p[i], p[(i + 1) % n])) &&
          (p[i].x - q.x) * (p[(i + 1) % n].x - q.x) < eps &&
          (p[i].y - q.y) * (p[(i + 1) % n].y - q.y) < eps)
        return 0;
      else if (!sgn(cross(q, q2, p[i])))
        break;
      else if (cross(q, p[i], q2) * cross(q, p[(i + 1) % n], q2) < -eps &&
               cross(p[i], q, p[(i + 1) % n]) *
                       cross(p[i], q2, p[(i + 1) % n]) <
                   -eps)
        count++;
  return count & 1;
}
int ons(P px, line l) {
  return sgn(cross(l.a, l.b, px)) == 0 && !(px < l.a || l.b < px);
}
void pp() {
  int fk = 1;
  while (fk) {
    fk = 0;
    for (int i = 0; i < n; i++)
      for (int q = 0; q < n; q++) {
        if (i == q) continue;
        P px;
        if (intersection(l[i], l[q], px) == 2) {
          if (ons(l[i].a, l[q]) || ons(l[i].b, l[q])) {
            if (l[q].a < l[i].a) l[i].a = l[q].a;
            if (l[i].b < l[q].b) l[i].b = l[q].b;
            fk = 1;
            swap(l[q], l[n - 1]);
            q--, n--;
          }
        }
      }
  }
  id.clear();
  pid = 0;
  for (int i = 0; i < n; i++) {
    P a[123];
    int ind = 0;
    for (int q = 0; q < n; q++) {
      ind += ins(l[i], l[q], a[ind]);
    }
    a[ind++] = l[i].a;
    a[ind++] = l[i].b;
    sort(a, a + ind);
    for (int i = 0; i < ind - 1; i++) {
      if (a[i] == a[i + 1]) continue;
      to[fd(a[i])].push_back(fd(a[i + 1]));
      to[fd(a[i + 1])].push_back(fd(a[i]));
    }
  }
  for (int i = 0; i < n; i++) {
  }
  n = pid;
  for (int i = 0; i < n; i++) {
    zk = i;
    sort(to[i].begin(), to[i].end(), pt);
    to[i].erase(unique(to[i].begin(), to[i].end()), to[i].end());
  }
}
vector<P> pd;
double dfs(int u, int v) {
  if (bj[u][v]++) return 0;
  pd.push_back(p[u]);
  int k = 0;
  while (to[v][k] != u) k++;
  k++;
  k %= to[v].size();
  k = to[v][k];
  return p[u] * p[v] + dfs(v, k);
}
struct A {
  double s;
  vector<int> to;
  vector<P> p;
} tree[12312];
struct B {
  double s;
  vector<int> to;
  string ys;
} ans[123231];
int pt2(const A& a, const A& b) { return a.s > b.s; }
void cr(int fa, int k) {
  for (int i = 0; i < tree[fa].to.size(); i++) {
    if (inp(tree[k].p[0], tree[tree[fa].to[i]].p)) {
      cr(tree[fa].to[i], k);
      return;
    }
  }
  tree[fa].s -= tree[k].s;
  tree[fa].to.push_back(k);
}
int f[12323], fid[12323];
int lid[123];
int ff(int k) {
  int fk = k, zk;
  while (fk != f[fk]) fk = f[fk];
  while (k != fk) zk = f[k], f[k] = fk, k = zk;
  return fk;
}
int nn;
void gaotu(int& m) {
  for (int i = 0; i < n; i++) f[i] = i;
  for (int i = 0; i < n; i++)
    for (int q = 0; q < to[i].size(); q++) f[ff(i)] = ff(to[i][q]);
  memset(fid, 0, sizeof(fid));
  for (int i = 0; i < n; i++) {
    if (fid[ff(i)] == 0) {
      ans[m].s = 0;
      fid[ff(i)] = m++;
    }
  }
}
int gao() {
  int da = 0;
  for (int i = 0; i < n; i++) {
    for (int q = 0; q < to[i].size(); q++) {
      if (!bj[i][to[i][q]]) {
        pd.clear();
        double fk = dfs(i, to[i][q]);
        if (fk > -eps) {
          tree[da].p = pd;
          tree[da].s = fk / 2;
          da++;
        }
      }
    }
  }
  sort(tree, tree + da, pt2);
  for (int i = 1; i < da; i++) cr(0, i);
  for (int i = 0; i < da; i++) ans[i].s = tree[i].s;
  gaotu(da);
  for (int i = 0; i < da; i++) {
    if (tree[i].p.size()) {
      if (ans[i].s > eps)
        ans[i].ys = "white";
      else
        ans[i].ys = "black";
      ans[i].to.push_back(fid[ff(fd(tree[i].p[0]))]);
      ans[fid[ff(fd(tree[i].p[0]))]].to.push_back(i);
      for (int q = 0; q < tree[i].to.size(); q++) {
        ans[i].to.push_back(fid[ff(fd(tree[tree[i].to[q]].p[0]))]);
        ans[fid[ff(fd(tree[tree[i].to[q]].p[0]))]].to.push_back(i);
      }
    } else {
      if (fid[ff(fd(P(0, 0)))] == i)
        ans[i].ys = "white";
      else
        ans[i].ys = "black";
    }
  }
  for (int i = 0; i < nn; i++)
    for (int q = 0; q < n; q++) {
      if (ons(p[q], l[i])) {
        lid[i] = fid[ff(q)];
      }
    }
  return da;
}
void ot2() {
  for (int i = 0; i < n; i++) {
    cout << i << "  " << tree[i].p.size() << "      " << ans[i].s << "  "
         << ans[i].ys << "  -->>   ";
    for (int q = 0; q < ans[i].to.size(); q++) cout << ans[i].to[q] << "  ";
    cout << endl;
  }
}
void ot() {
  map<string, double> mp;
  for (int i = 0; i < n; i++) {
    mp[ans[i].ys] += ans[i].s;
  }
  for (map<string, double>::iterator it = mp.begin(); it != mp.end(); it++) {
    cout << it->first << ' ';
    printf("%.10lf\n", it->second);
  }
}
int ddfs(int k, P px) {
  for (int i = 0; i < tree[k].to.size(); i++) {
    if (inp(px, tree[tree[k].to[i]].p)) return ddfs(tree[k].to[i], px);
  }
  return k;
}
int fs(P px) {
  for (int i = 0; i < nn; i++) {
    if (ons(px, l[i])) {
      return lid[i];
    }
  }
  return ddfs(0, px);
}
void ph(int k, string s, string ss) {
  if (ans[k].ys != s) return;
  ans[k].ys = ss;
  for (int i = 0; i < ans[k].to.size(); i++) ph(ans[k].to[i], s, ss);
}
void qiu() {
  int m;
  cin >> m;
  while (m--) {
    P px;
    px.input();
    string s;
    cin >> s;
    int ik = fs(px);
    if (ans[ik].ys == s) continue;
    ph(ik, ans[ik].ys, s);
  }
}
int main() {
  double H, W;
  while (cin >> W >> H >> n) {
    nn = n;
    bj.clear();
    for (int i = 0; i < 10000; i++)
      to[i].clear(), tree[i].to.clear(), ans[i].to.clear();
    for (int i = 0; i < n; i++) l[i].a.input(), l[i].b.input();
    l[n++] = line(P(0, 0), P(W, 0));
    l[n++] = line(P(0, 0), P(0, H));
    l[n++] = line(P(W, H), P(W, 0));
    l[n++] = line(P(W, H), P(0, H));
    for (int i = 0; i < n; i++)
      if (l[i].a > l[i].b) swap(l[i].a, l[i].b);
    pp();
    n = gao();
    qiu();
    ot();
  }
}