////////////////////////////////////////////////////////////////////////////////
// 平面幾何

// 型変換できるもの
//   double  -> Point
//   Segment -> Line

// 誤差の話：絶対誤差でも相対誤差でも死ぬ例
// int main(){
//   const double EPS = 1e-9;
//   double a = 1.3, b = 1e8, c = a + b;
//   c = c - b;
//   printf("%d\n", equal(a, c));          // => 0
//   printf("%d\n", relative_equal(a, c)); // => 0
// }

////////////////////
// ライブラリ
#include<cmath>
#include<algorithm>
#include<cassert>
////////////////////
// 定数
const double EPS = 1e-9;                // |EPS|未満の数は0として扱う
////////////////////
// 構造体
struct Point {
  double x, y;
  Point(const double d = 0.0) :x(d), y(d) {}
  Point(const double x, const double y) :x(x), y(y) {}
};
struct Segment {
  Point initial, terminal;
  Segment(const Point& initial, const Point& terminal) :initial(initial), terminal(terminal) {}
  Segment(const double x1, const double y1, const double x2, const double y2) :initial(x1, y1), terminal(x2, y2) {}
};
struct Line {
  Point initial, terminal;
  Line(const Point& initial, const Point& terminal) :initial(initial), terminal(terminal) {}
  Line(const double x1, const double y1, const double x2, const double y2) :initial(x1, y1), terminal(x2, y2) {}
  Line(const Segment& s) :initial(s.initial), terminal(s.terminal) {}
};
////////////////////
// 実装
bool relative_equal(const double d1, const double d2) {return d1 == 0 ? std::abs(d2) < EPS : std::abs((d1 - d2) / d1) < EPS;}
// 演算子オーバーロード
bool operator==(const Point& lhs, const Point& rhs) {return relative_equal(lhs.x, rhs.x) && relative_equal(lhs.y, rhs.y);}
bool operator<(const Point& lhs, const Point& rhs) {return lhs.x != rhs.x ? lhs.x < rhs.x : lhs.y < rhs.y;}
bool operator>(const Point& lhs, const Point& rhs) {return lhs.x != rhs.x ? lhs.x > rhs.x : lhs.y > rhs.y;}
bool operator!=(const Point& lhs, const Point& rhs) {return !(lhs == rhs);}
bool operator<=(const Point& lhs, const Point& rhs) {return !(lhs > rhs);}
bool operator>=(const Point& lhs, const Point& rhs) {return !(lhs < rhs);}
const Point operator+(const Point& lhs, const Point& rhs) {return Point(lhs.x + rhs.x, lhs.y + rhs.y);}
const Point operator-(const Point& lhs, const Point& rhs) {return Point(lhs.x - rhs.x, lhs.y - rhs.y);}
const Point operator*(const Point& lhs, const Point& rhs) {return Point(lhs.x * rhs.x, lhs.y * rhs.y);}
const Point operator/(const Point& lhs, const Point& rhs) {return Point(lhs.x / rhs.x, lhs.y / rhs.y);}
const Point operator-(const Point& p) {return Point(-p.x, -p.y);}
// 点
double abs(const Point& p) {return std::hypot(p.x, p.y);}
double norm(const Point& p) {return p.x * p.x + p.y * p.y;}
double dot(const Point& a, const Point& b) {return a.x * b.x + a.y * b.y;}
double cross(const Point& a, const Point& b) {return a.x * b.y - a.y * b.x;}
// const Point normalize(const Point& p) {return p / abs(p);}
// 線
bool parallel(const Line& l1, const Line& l2) {return std::abs(cross(l2.terminal - l2.initial, l1.terminal - l1.initial)) < EPS;}
bool orthogonal(const Line& l1, const Line& l2) {return std::abs(dot(l2.terminal - l2.initial, l1.terminal - l1.initial)) < EPS;}
// 点の位置関係
enum POSITION {ONLINE_FRONT = -2, CLOCKWISE, ON_SEGMENT, COUNTER_CLOCKWISE, ONLINE_BACK}; 
POSITION ccw(const Point& a, const Point& b, const Point& p) {
  Point v1 = b - a;
  Point v2 = p - a;
  if(cross(v1, v2) >= EPS) return COUNTER_CLOCKWISE;
  if(cross(v1, v2) <= -EPS) return CLOCKWISE;
  if(dot(v1, v2) <= -EPS) return ONLINE_BACK;
  if(norm(v1) < norm(v2)) return ONLINE_FRONT;              // 誤差怖い
  return ON_SEGMENT;
}
// 交差判定
bool intersect(const Point& p1, const Point& p2) {return p1 == p2;}
bool intersect(const Point& p, const Segment& s) {return abs(p - s.initial) + abs(p - s.terminal) - abs(s.initial - s.terminal) <= EPS;}
bool intersect(const Segment& s, const Point& p) {return intersect(p, s);}
bool intersect(const Point& p, const Line& l) {return !parallel(Line(p, l.initial), Line(p, l.terminal));}
bool intersect(const Line& l, const Point& p) {return intersect(p, l);}
bool intersect(const Segment& s1, const Segment& s2) {
  return ccw(s1.initial, s1.terminal, s2.initial) * ccw(s1.initial, s1.terminal, s2.terminal) <= 0
      && ccw(s2.initial, s2.terminal, s1.initial) * ccw(s2.initial, s2.terminal, s1.terminal) <= 0;
}
bool intersect(const Segment& s, const Line& l) {
  auto v1 = l.terminal - l.initial;
  auto v2 = s.initial  - l.initial;
  auto v3 = s.terminal - l.initial;
  return cross(v1, v2) * cross(v1, v3) <= EPS;
}
bool intersect(const Line& l, const Segment& s) {return intersect(s, l);}
bool intersect(const Line& l1, const Line& l2) {return !parallel(l1, l2) || intersect(l1.initial, l2);}
// 点の移動
Point projection(const Point& p, const Line& l) {
  auto v = l.initial - l.terminal;
  return l.initial + dot(p - l.initial, v) / norm(v) * v;
}
Point projection(const Line& l, const Point& p) {return projection(p, l);}
Point reflection(const Point& p, const Line& l) {return p + 2 * (projection(p, l) - p);}
Point reflection(const Line& l, const Point& p) {return reflection(p, l);}
// 距離
double distance(const Point& p1, const Point& p2) {
  auto p = p1 - p2;
  return hypot(p.x, p.y);
}
double distance(const Point& p, const Segment& s) {
  auto r = projection(s, p);
  return intersect(r, s) ? distance(p, r) : std::min(distance(p, s.initial), distance(p, s.terminal));
}
double distance(const Segment& s, const Point& p) {return distance(p, s);}
double distance(const Point& p, const Line& l) {return distance(p, projection(p, l));}
double distance(const Line& l, const Point& p) {return distance(p, l);}
double distance(const Segment& s1, const Segment& s2) {
  return intersect(s1, s2) ? 0.0 : std::min({distance(s1, s2.initial), distance(s1, s2.terminal), distance(s2, s1.initial), distance(s2, s1.terminal)});
}
double distance(const Segment& s, const Line& l) {return intersect(s, l) ? 0.0 : std::min(distance(s.initial, l), distance(s.terminal, l));}
double distance(const Line& l,const Segment& s) {return distance(s, l);}
double distance(const Line& l1, const Line& l2) {return intersect(l1, l2) ? 0.0 : distance(l1.initial, l2);}
// 交点
const Point crosspoint(const Line& l1, const Line& l2) {
  assert(intersect(l1, l2));
  if(parallel(l1, l2)) return l1.initial;                   // 平行なときl1の始点を返す
  double A = cross(l1.terminal - l1.initial, l2.terminal - l2.initial);
  double B = cross(l1.terminal - l1.initial, l1.terminal - l2.initial);
  return l2.initial + B / A * (l2.terminal - l2.initial);
}
const Point crosspoint(const Segment& s, const Line& l) {
  assert(intersect(s, l));
  if(parallel(s, l)) return s.initial;
  Point cp = crosspoint(Line(s), l);
  assert(intersect(s, cp));
  return cp;
}
const Point crosspoint(const Line& l, const Segment& s) {return crosspoint(s, l);}
const Point crosspoint(const Segment& s1, const Segment& s2) {
  assert(intersect(s1, s2));
  if(parallel(s1, s2)) {                                    // 平行なときいずれかの端点を返す
    if(intersect(s1.initial,  s2)) return s1.initial;
    if(intersect(s1.terminal, s2)) return s1.terminal;
    if(intersect(s2.initial,  s1)) return s2.initial;
    if(intersect(s2.terminal, s1)) return s2.terminal;
  }
  return crosspoint(Line(s1), Line(s2));
}
// デバッグ用
#include<bits/stdc++.h>
using namespace std;
void print(const Point& p) {cout<<"point: "; cout<<"("<<p.x<<","<<p.y<<")";}
void print(const Segment& l) {cout<<"segment: "; print(l.initial); cout<<" - ";print(l.terminal);}
void print(const Line& l) {cout<<"line: "; print(l.initial); cout<<" - ";print(l.terminal);}
////////////////////////////////////////////////////////////////////////////////
// 多角形
//   辺をメンバ変数にしない→メモリ節約・edge(void)がO(頂点数)。edge().begin()を使っている箇所は書き換える必要がある
#include<vector>
#include<algorithm>
#include<numeric>
#include<utility>
class Polygon {
public:
  // 編集
  void add(const Point& p) {
    if(!vertex_.empty()) {
      if(!edge_.empty()) edge_.pop_back();
      edge_.push_back(Segment(vertex_.back(), p));
      edge_.push_back(Segment(p, vertex_.front()));
    }
    vertex_.push_back(p);
  }
  void clear() {
    vertex_.clear();
    edge_.clear();
  };
  // 情報
  int size() const {return vertex_.size();}
  Point vertex(const int n) const {return vertex_.at(n);}
  Segment edge(const int n) const {return edge_.at(n);}
  const std::vector<Point>& vertex() const {return vertex_;}
  const std::vector<Segment>& edge() const {return edge_;}
  // 道具
  bool touch(const Point& p) const {
    return std::any_of(edge().begin(), edge().end(), [=](const Segment& s) {return ccw(s.initial, s.terminal, p) == ON_SEGMENT;});
  }
  bool intersect(const Point& p) const {
    bool in = false;                    // p=(x,y)から(INF,y)への半直線と多角形とが交差する回数 mod 2
    for(const auto& e: edge()) {
      if(::intersect(p, e)) return true;
      Point a = e.initial  - p;
      Point b = e.terminal - p;
      if(a.y > b.y) std::swap(a, b);
      if(a.y <= 0.0 && 0.0 < b.y && cross(a, b) < EPS) in = !in;                // 誤差怖い
    }
    return in;
  }
  double area() const {
    return std::abs(std::accumulate(edge().begin(), edge().end(), 0, [=](const int sum, const Segment& e){return sum + cross(e.initial, e.terminal);})) / 2.0;
  }
  bool convex() const {
    bool positive = false;
    bool negative = false;
    for(int i = 0; i < size(); ++i) {
      auto position = ccw(vertex(i), vertex((i + 1) % size()), vertex((i + 2) % size()));
      positive |= position == CLOCKWISE;
      negative |= position == COUNTER_CLOCKWISE;
      if(negative && positive) return false;
    }
    return true;
  }
private:
  std::vector<Point> vertex_;
  std::vector<Segment> edge_;
};
////////////////////////////////////////////////////////////////////////////////
#include<bits/stdc++.h>
using namespace std;
int main() {
  // Points/Vectors
  // A
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  Line l(Point(a, b), Point(c, d));
  int q;
  for(cin >> q; q > 0; --q) {
    int x, y;
    cin >> x >> y;
    Point p = projection(Point(x, y), l);
    cout << setprecision(10) << fixed << p.x << " " << p.y << endl;
  }
//   // C
//   int a, b, c, d;
//   cin >> a >> b >> c >> d;
//   Segment s(Point(a, b), Point(c, d));
//   int q;
//   for(cin >> q; q > 0; --q) {
//     int x, y;
//     cin >> x >> y;
//     switch(ccw(s.initial, s.terminal, Point(x, y))) {
//     case COUNTER_CLOCKWISE:
//       cout << "COUNTER_CLOCKWISE" << endl;
//       break;
//     case CLOCKWISE:
//       cout << "CLOCKWISE" << endl;
//       break;
//     case ONLINE_BACK:
//       cout << "ONLINE_BACK" << endl;
//       break;
//     case ONLINE_FRONT:
//       cout << "ONLINE_FRONT" << endl;
//       break;
//     case ON_SEGMENT:
//       cout << "ON_SEGMENT" << endl;
//       break;
//     }
//   }

  // Segments/Lines
//   int n;
//   for(cin >> n; n > 0; --n) {
//     int a, b, c, d, e, f, g, h;
//     cin >> a >> b >> c >> d >> e >> f >> g >> h;
//     Segment s(Point(a, b), Point(c, d));
//     Segment t(Point(e, f), Point(g, h));
//     // A
// //     cout << (parallel(s, t) ? 2 : (orthogonal(s, t) ? 1 : 0)) << endl;
//     // B
// //     cout << (intersect(s, t) ? 1 : 0) << endl;
//     // C
// //     auto cp = crosspoint(s, t);
// //     cout << setprecision(10) << fixed << cp.x << " " << cp.y << endl;
//     // D
// //     cout << setprecision(10) << fixed << distance(s, t) << endl;
//   }

  // Polygon
//   int n;
//   Polygon polygon;
//   for(cin >> n; n > 0; --n) {
//     int x, y;
//     cin >> x >> y;
//     polygon.add(Point(x, y));
//   }
//   // A
// //   cout << setprecision(1) << fixed  << polygon.area() << endl;
//   // B
// //   cout << (polygon.convex() ? 1 : 0) << endl;
//   // C
//   int q;
//   for(cin >> q; q > 0; --q) {
//     int x, y;
//     cin >> x >> y;
//     Point p(x, y);
//     cout << (polygon.touch(p) ? 1 : (polygon.intersect(p) ? 2 : 0)) << endl;
//   }
}

Measured memory_bytes: 1236