#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class H> void rsz(V<T> &v, H h) { v.resize(h); }
template<class T, class H, class... R> void rsz(V<T> &v, H h, R... r) { v.resize(h); for (auto&& i : v) rsz(i, r...); }
using C = complex<double>;

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int x, y; cin >> x >> y; C p1(x, y);
  cin >> x >> y; C p2(x, y);
  int q; cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> x >> y; C p(x, y);
    C x = p1 + real(conj(p2 - p1) * (p - p1)) / norm(p2 - p1) * (p2 - p1);
    cout << fixed << setprecision(10) << real(x) << ' ' << imag(x) << '\n';
  }
}
