#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long int> locx(n, 0), locy(n, 0);
  vector<long long int> cx(m, 0), cy(m, 0);
  vector<int> id(n, -1);
  for (int i = 0; i < n; i++) {
    cin >> locx[i] >> locy[i];
  }
  for (int j = 0; j < m; j++) {
    cin >> cx[j] >> cy[j];
  }
  for (int i = 0; i < n; i++) {
    cout << locx[i] << "," << locy[i] << endl;
  }
  for (int i = 0; i < n; i++) {
    cout << cx[i] << "," << cy[i] << endl;
  }
  for (int i = 0; i < n; i++) {
    int min = INT_MAX;
    int imin = -1;
    for (int j = 0; j < m; j++) {
      int dist = abs(locx[i] - cx[j]) + abs(locy[i] - cy[j]);
      if (dist < min) {
        min = dist;
        imin = j;
      }
    }
    id[i] = imin;
  }
  for (int i : id) {
    cout << i + 1 << endl;
  }
}
