#include <bits/stdc++.h>

using namespace std;

namespace arithmetic {
  template<typename T> class Addition {
  public:
    T operator+(const T& v) const {
      T res(static_cast<const T&>(*this));
      return res += v;
    }
  };

  template<typename T> class Subtraction {
  public:
    T operator-(const T& v) const {
      T res(static_cast<const T&>(*this));
      return res -= v;
    }
  };

  template<typename T> class Multiplication {
  public:
    T operator*(const T& v) const {
      T res(static_cast<const T&>(*this));
      return res *= v;
    }
  };

  template<typename T> class Division {
  public:
    T operator/(const T& v) const {
      T res(static_cast<const T&>(*this));
      return res /= v;
    }
  };
}

template<typename T> class IndivisibleArithmetic : public arithmetic::Addition<T>, public arithmetic::Subtraction<T>, public arithmetic::Multiplication<T> {};

template<typename T> class Arithmetic : public IndivisibleArithmetic<T>, public arithmetic::Division<T> {};

template<typename T> class Ordered {
public:
  bool operator==(const T& v) const {
    return !(v < static_cast<const T&>(*this) || static_cast<const T&>(*this) < v);
  }
  
  bool operator!=(const T& v) const {
    return v < static_cast<const T&>(*this) || static_cast<const T&>(*this) < v;
  }

  bool operator>(const T& v) const {
    return v < static_cast<const T&>(*this);
  }

  bool operator<=(const T& v) const {
    return !(v < static_cast<const T&>(*this));
  }

  bool operator>=(const T& v) const {
    return !(static_cast<const T&>(*this) < v);
  }
};

class Real : public Arithmetic<Real>, public Ordered<Real> {
private:
  static long double EPS;
  long double val;

public:
  Real() {}

  Real(long double val) : val(val) {}

  Real operator+=(const Real& r) {
    val += r.val;
    return *this;
  }
  
  Real operator-=(const Real& r) {
    val -= r.val;
    return *this;
  }
  
  Real operator*=(const Real& r) {
    val *= r.val;
    return *this;
  }
  
  Real operator/=(const Real& r) {
    val /= r.val;
    return *this;
  }

  bool operator<(Real r) const {
    return val < r.val - EPS;
  }

  operator long double() {
    return val;
  }
};

long double Real::EPS = 1e-8;

ostream& operator<<(ostream& os, Real a) {
	os << (long double)a;
	return os;
}

istream& operator>>(istream& is, Real& a) {
	long double n;
	is >> n;
	a = n;
	return is;
}

class Point : public Arithmetic<Point> {
public:
  Real x, y;
  
  Point() {}

  Point (const Real& x, const Real& y) : x(x), y(y) {}
  
  Point operator+=(const Point& p) {
    x += p.x;
    y += p.y;
    return *this;
  }

  Point operator-=(const Point& p) {
    x -= p.x;
    y -= p.y;
    return *this;
  }

  Point operator*=(const Point& p) {
    Real xx = x * p.x - y * p.y;
    Real yy = x * p.y + y * p.x;
    return *this = Point(xx, yy);
  }

  Point operator/=(const Point& p) {
    Real nrm = p.norm();
    Real xx = (x * p.x + y * p.y) / nrm;
    Real yy = (x * p.y - y * p.x) / nrm;
    return *this = Point(xx, yy);
  }

  Point operator*=(const Real& r) {
    x *= r;
    y *= r;
    return *this;
  }

  Point operator*(const Real& r) const {
    Point res(static_cast<const Point&>(*this));
    return res *= r;
  }

  Real norm() const {
    return x * x + y * y;
  }

  Real abs() const {
    return sqrt(norm());
  }
};

ostream& operator<<(ostream& os, const Point& point) {
	os << "(" << point.x << "," << point.y << ")";
	return os;
}

istream& operator>>(istream& is, Point& point) {
  Real x, y;
	is >> x >> y;
	point = Point(x, y);
	return is;
}

class Line {
public:
  Point a, b;

  Line() {}

  Line (const Point& a, const Point& b) : a(a), b(b) {}
  
  Point vec() const {
    return b - a;
  }
};

ostream& operator<<(ostream& os, const Line& line) {
	os << "[" << line.a << "," << line.b << "]";
	return os;
}

istream& operator>>(istream& is, Line& line) {
  Point a, b;
  is >> a >> b;
  line = Line(a, b);
  return is;
}

inline Point projection(const Point& a, const Point &b) {
  return a * (b / a).x;
}

inline Point perpendicular(const Line& line, const Point& point) {
  return line.a + projection(line.vec(), point - line.a);
}

int main() {
  Point p1, p2;
  cin >> p1 >> p2;
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    Point p, r;
    cin >> p;
    r = perpendicular(Line(p1, p2), p);
    cout << fixed << setprecision(15) << r.x << " " << fixed << setprecision(15) << r.y << endl;
  }
}

Measured memory_bytes: 1292