#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();
  }
}
