#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <complex>
#include <deque>
#include <functional>
#include <initializer_list>
#include <math.h>
#include <map>
#include <random>
#include <set>
#include <stack>
#include <tuple>
#include <type_traits>
#include <queue>
#include <vector>

using lli = long long int;
using pii = std::pair<int, int>;

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))

// グリッド上の縦横移動
constexpr std::array<std::pair<int, int>, 4> dxdy = {
    { {1, 0}, {-1, 0}, {0, 1}, {0, -1} }
};


template <typename T> inline bool chmin(T& a, T b){ if(b < a){ a = b; return true; } return false; }
template <typename T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }

inline bool isIn(int x, int y, int H, int W){return 0 <= x and x < H and 0 <= y and y < W;}
inline auto isInTheGrid(const int H, const int W){
    return std::bind(isIn, std::placeholders::_1, std::placeholders::_2, H, W);
}
inline bool bitUP(int state, int k){ return (state >> k) & 1; }
inline bool bitUP(long long int state, int k){ return (state >> k) & 1;}


namespace MyInputAndOutput{
    // 入力関係 (cin)
    class user_input{
    private:
        static constexpr unsigned int sizeOfAscii = 128;
        bool isBlankChar[sizeOfAscii];
            /*  < definition of getchar >
                reference
                MacOS   : https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/getchar.3.html
                Windows : https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/getchar-nolock-getwchar-nolock?view=vs-2019
                Linux   : https://linux.die.net/man/3/unlocked_stdio 
                Ubuntu  : http://manpages.ubuntu.com/manpages/trusty/man3/getchar_unlocked.3posix.html
            */
            #if defined(__APPLE__)
                #define DAGGER_GETCHAR_UNLOCKED_DAGGER getchar_unlocked
            #elif defined(_WIN32) || defined(_WIN64)
                #define DAGGER_GETCHAR_UNLOCKED_DAGGER _getchar_nolock
            #elif defined(__linux) 
                #if _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE || _BSD_SOURCE || _SVID_SOURCE
                    #define DAGGER_GETCHAR_UNLOCKED_DAGGER getchar_unlocked
                #else
                    #define DAGGER_GETCHAR_UNLOCKED_DAGGER getchar
                #endif
            #else
                #define DAGGER_GETCHAR_UNLOCKED_DAGGER getchar
            #endif
        // 符号あり整数を getchar で読み込んで構成する (もし, 0 ~ 9 以外の文字が含まれると困る)
        template <typename Tp>
        inline void charToInteger(Tp& val) const {
            val = 0; int c; while(true){
                c = DAGGER_GETCHAR_UNLOCKED_DAGGER();
                if(c == EOF) return;
                if('-' or (not isBlankChar[c])) break;
            }
            if(c == '-'){
                while(true){
                    c = DAGGER_GETCHAR_UNLOCKED_DAGGER();
                    if(c < '0' or c > '9') break;
                    val = 10 * val + c - '0';
                } val = -val;
            }
            else{
                if(c < '0' or c > '9') return;
                do{
                    val = 10 * val + c - '0';
                    c = DAGGER_GETCHAR_UNLOCKED_DAGGER();
                } while('0' <= c and c <= '9');
            }
        }
        // 符号なし整数を getchar で読み込んで構成する (もし, 符号付きだとバグる)
        template <typename Tp>
        inline void charToUnsignedInteger(Tp& val) const {
            val = 0; int c; while(true){
                c = DAGGER_GETCHAR_UNLOCKED_DAGGER();
                if(c == EOF) return;
                if(not isBlankChar[c]) break;
            }
            if(c < '0' or c > '9') return;
            do{
                val = 10 * val + c - '0';
                c = DAGGER_GETCHAR_UNLOCKED_DAGGER();
            } while(not (c == EOF or isBlankChar[c]));
        }
    public:
        constexpr user_input(void) : isBlankChar(){
            for(unsigned int i = 0; i < sizeOfAscii; ++i) isBlankChar[i] = false;
            isBlankChar[int('\n')] = true; isBlankChar[int('\t')] = true; 
            isBlankChar[int(' ')]  = true; isBlankChar[int('\v')] = true;
        }
        inline const user_input& operator >> (int& int_arg) const {
            //scanf("%d", &int_arg);
            charToInteger<int>(int_arg); return *this;
        }
        inline const user_input& operator >> (long long int& llint_arg) const {
            //scanf("%lld", &llint_arg); return *this;
            charToInteger<long long int>(llint_arg); return *this;
        }
        inline const user_input& operator >> (unsigned int& uint_arg) const {
            //scanf("%u", &uint_arg); 
            charToUnsignedInteger<unsigned int>(uint_arg); return *this;
        }
        inline const user_input& operator >> (unsigned long long int& ullint_arg) const {
            //scanf("%llu", &ullint_arg);
            charToUnsignedInteger<unsigned long long int>(ullint_arg); return *this;
        }
        inline const user_input& operator >> (unsigned long& ulint_arg) const {
            charToUnsignedInteger<unsigned long>(ulint_arg); return *this;
        }
        inline const user_input& operator >> (float& float_arg) const {
            scanf("%f", &float_arg); return *this;
        }
        inline const user_input& operator >> (double& double_arg) const {
            scanf("%lf", &double_arg); return *this;
        }
        inline const user_input& operator >> (long double& ldouble_arg) const {
            scanf("%Lf", &ldouble_arg); return *this;
        }
        inline const user_input& operator >> (char* str_arg) const {
            scanf("%s", str_arg); 
            return *this;
        }
        inline const user_input& operator >> (char& char_arg) const {
            do{
                if((char_arg = DAGGER_GETCHAR_UNLOCKED_DAGGER()) == EOF) return *this;
            } while(isBlankChar[int(char_arg)]);
            return *this;
        }
        inline const user_input& operator >> (std::string& str_arg) const {
            str_arg.erase();
            int c; while(true){ 
                c = DAGGER_GETCHAR_UNLOCKED_DAGGER();
                if(c == EOF) return *this;
                if(not isBlankChar[c]) break;
            }
            constexpr unsigned int buffer_size = 128; 
            char buffer_input[buffer_size]; unsigned int buffer_length = 0;
            do{
                buffer_input[buffer_length++] = c;
                if(buffer_length == buffer_size){
                    buffer_length = 0; str_arg.append(buffer_input, buffer_size);
                }
                c = DAGGER_GETCHAR_UNLOCKED_DAGGER();
            } while(c != EOF and (not isBlankChar[c]) );
            str_arg.append(buffer_input, buffer_length);
            return *this;
        }
        template <typename S, typename T>
        inline const user_input& operator >>(std::pair<S, T>& pair_arg) const{
            (*this) >> pair_arg.first >> pair_arg.second; return *this;
        }
        template <typename T>
        inline const user_input& operator >>(std::vector<T>& vec) const {
            for(T& ele : vec) (*this) >> ele; 
            return *this;
        }
        // getchar の define の解除
        #undef DAGGER_GETCHAR_UNLOCKED_DAGGER
    }; constexpr user_input cin;

    void ends(void) {putchar('\0'); }
    void endl(void) {putchar('\n'); fflush(stdout);}
    void flush(void) {fflush(stdout);}

    // 出力関係 (cout)
    class user_output{
    public:
        constexpr user_output(void){}
        inline const user_output& operator << (const int int_arg) const{
            printf("%d", int_arg); return *this;
        }
        inline const user_output& operator << (const unsigned int uint_arg) const{
            printf("%u", uint_arg); return *this;
        }
        inline const user_output& operator << (const long long int llint_arg) const {
            printf("%lld", llint_arg); return *this;
        }
        inline const user_output& operator << (const unsigned long long int ullint_arg) const {
            printf("%llu", ullint_arg); return *this;
        }
        inline const user_output& operator << (const unsigned long ulint_arg) const {
            printf("%lu", ulint_arg); return *this;
        }
        inline const user_output& operator << (const float flt_arg) const {
            printf("%.16f", flt_arg); return *this;
        }
        inline const user_output& operator << (const double ld_arg) const {
            printf("%.16lf", ld_arg); return *this;
        }
        inline const user_output& operator << (const long double ld_arg) const {
            printf("%.16Lf", ld_arg); return *this;
        }
        inline const user_output& operator << (const char char_arg) const {
            putchar(char_arg); return *this;
        }
        inline const user_output& operator << (const unsigned char uchar_arg) const {
            putchar(uchar_arg); return *this;
        }
        inline const user_output& operator << (const char* str_arg) const {
            fputs(str_arg, stdout); return *this;
        }
        inline const user_output& operator << (const std::string& str_arg) const {
            fputs(str_arg.c_str(), stdout); return *this;
        }
        inline const user_output& operator << (void(* const func_arg)(void)) const {
            func_arg(); return *this;
        }
        template <typename S, typename T>
        inline const user_output& operator <<(const std::pair<S, T>& pair_arg) const{
            (*this) << pair_arg.first << ' ' << pair_arg.second; return *this;
        }
        template <typename Tp_name>
        inline const user_output& operator << (const std::vector<Tp_name>& vec) const {
            const size_t size_of_vec = vec.size();
            if(size_of_vec <= 0) return *this;
            (*this) << vec[0]; 
            for(size_t index = 1; index < size_of_vec; ++index) (*this) << ' ' << vec[index];
            return *this;
        }
    }; constexpr user_output cout;

    // その他出力関数
    void binary_output(int64_t value, size_t length = 64){
        char out[length + 1];
        for(size_t i = 0; i < length; ++i) out[length - 1 - i] = ((value >> i) & 1) ? '1' : '0';
        out[length] = '\0'; puts(out);
    }
    template <typename InputType>
    void print(InputType first, InputType last, const char separate_c = ' ', const char end_c = '\n'){
        InputType it = first;
        while(true){
            MyInputAndOutput::cout << *it;
            if(++it == last){MyInputAndOutput::cout << end_c; return;}
            MyInputAndOutput::cout << separate_c;  
        }
    }
}; namespace MIO = MyInputAndOutput;

// z-algorithm
template <class T> std::vector<unsigned int> z_algorithm(const T &str) {
    const size_t n = str.size();
    std::vector<unsigned int> resOfCP(n); resOfCP[0] = n;
    int i = 1, j = 0;
    while (i < n) {
        while (i + j < n and str[j] == str[i + j]) ++j;
        resOfCP[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i + k < n and k + resOfCP[k] < j) resOfCP[i + k] = resOfCP[k], ++k;
        i += k; j -= k;
    }
    return resOfCP;
} 

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

namespace Geometory{
    // 点(ベクトル) を表すクラス
    template <typename real_type>
    class Point{
    private:
        static constexpr real_type PI = std::acos<real_type>(-1); // 円周率
        static constexpr real_type real_abs(const real_type v){ return std::fabs<real_type>(v); }
        static real_type real_sqrt(const real_type v);
    public:
        static constexpr real_type EPS = 1e-10; // 許容誤差
        // 誤差を許してゼロであるかを判定する関数
        static constexpr bool isZero(const real_type& v){ return -EPS < v and v < EPS;}
        // 符号を得る関数 : (a > 0) → 1,  (a ≒ 0) → 0, (a < 0) → -1
        static constexpr int sign(real_type v){
            return (v > EPS) ? 1 : ((v < -EPS) ? -1 : 0); 
        }

        real_type x, y; // メンバ変数 : 点 (x, y) を表す

        // コンストラクタ;
        constexpr Point(const real_type& x = 0, const real_type& y = 0): x(x), y(y){}

        // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 基本的演算 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        // 四則演算
        constexpr Point& operator += (const Point& other){ x += other.x; y += other.y; return *this; }
        constexpr Point& operator -= (const Point& other){ x -= other.x; y -= other.y; return *this; }
        constexpr Point& operator *= (const Point& other){
            const real_type&& tmp_x = x * other.x - y * other.y;
            (y *= other.x) += x * other.y; x = tmp_x; return *this;
        }
        constexpr Point& operator *= (const real_type& scalar){ x *= scalar; y *= scalar; return *this; }
        constexpr Point& operator /= (const real_type& scalar){ x /= scalar; y /= scalar; return *this; } 
        constexpr Point operator +  (const Point& other) const { return Point(*this) += other; }
        constexpr Point operator -  (const Point& other) const { return Point(*this) -= other; }
        constexpr Point operator -  (void) const { return Point(-x, -y); }
        constexpr Point operator *  (const Point& other) const { return Point(*this) *= other; }
        constexpr Point operator *  (const real_type& scalar) const { return Point(*this) *= scalar; }
        constexpr Point operator /  (const real_type& scalar) const { return Point(*this) /= scalar; }
        // ノルム(2乗), 絶対値, 一致判定, 内積 determinant, 偏角, rotate
        real_type norm(void) const { return x * x + y * y; }    // ノルム
        real_type abs(void) const { return real_sqrt(norm()); } // 絶対値 |A|
        inline constexpr bool operator == (const Point& other) const { // 一致判定
            return real_abs(x - other.x) < EPS and real_abs(y - other.y) < EPS;
        }
        // 内積を求める関数
        real_type dot(const Point& other) const { return x * other.x + y * other.y; }
        // 行列積を求める関数
        real_type determinant(const Point& other) const { return x * other.y - y * other.x; }
        // 偏角を求める関数 : rad
        real_type arg(void) const { return std::atan2<real_type>(y, x); }
        // 偏角を求める関数 : 180°単位
        real_type arg_degree(void) const { return arg() * 180 / PI; }
        // θ rad 回転(rotate)させる
        inline Point& rotate(const real_type& theta){
            const real_type 
                cos_theta = std::cos<real_type>(theta),
                sin_theta = std::sin<real_type>(theta);
            const real_type&& tmp_x = x * cos_theta - y * sin_theta;
            (y *= cos_theta) += x * sin_theta; x = tmp_x; return *this;
        }
        // xの値によってソート (ほぼ同じ場合は y の値でソート)
        inline constexpr bool  operator < (const Point& other) const {
            const int sgn = sign(x - other.x); if(sgn) return sgn < 0;
            return sign(y - other.y) < 0;
        }
        //friend const MIO::user_input& operator >> (const MIO::user_input& stream, Point<real_type>& point);
    };
    // テンプレート特殊化
    template <> float Point<float>::real_sqrt(const float v){ return sqrtf(v); }
    template <> double Point<double>::real_sqrt(const double v){ return sqrt(v); }
    template <> long double Point<long double>::real_sqrt(const long double v){ return sqrtl(v); }
    // 点クラス の入出力
    template <typename real_type>
    const MIO::user_input& operator >> (const MIO::user_input& stream, Point<real_type>& point){
        stream >> point.x >> point.y; return stream;
    }
    template <typename real_type>
    const MIO::user_output& operator << (const MIO::user_output& stream, const Point<real_type>& point){
        stream << point.x << ' ' << point.y; return stream;
    }

    // reference https://www.ioi-jp.org/camp/2017/2017-sp_camp-hide.pdf
    // see also  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C&lang=ja
    template <typename real_type> int iSP( const Point<real_type>& a,
                                       const Point<real_type>& b,
                                       const Point<real_type>& c ){
        const Point<real_type> b_a = b - a, c_a = c - a;
        const real_type a_origin_det = b_a.determinant(c_a);
        // 直線上にない場合
        if(a_origin_det >  Point<real_type>::EPS) return +1; // 左に曲がる : 反時計回り
        if(a_origin_det < -Point<real_type>::EPS) return -1; // 右に曲がる : 時計回り
        // 3点が一直線上の場合
        if(b_a.dot(c_a) < 0)        return +2; // c-a-b の順に並んでいる場合
        if(b_a.norm() < c_a.norm()) return -2; // a-b-c の順に並んでいる場合
        return  0; // それ以外の順番に並んでいる場合
    }

    // 直線 を表すクラス (2点 p0, p1 を通る直線)
    template <typename real_type> class Line{
    public:
        std::array<Point<real_type>, 2> point; // 通るべき2点

        // コンストラクタ : 点 p1, p2 を通る直線
        constexpr Line( const Point<real_type>& p1, const Point<real_type>& p2): point({{p1, p2}}){}
        // コンストラクタ : 直線 Ax + By = C
        constexpr Line(const real_type& A = 1, const real_type& B = 1, const real_type& C = 0){
            if(std::fabs<real_type>(A) < Point<real_type>::EPS){ point[0](0, C / B); point[1](1, C / B); }
            else if(std::fabs<real_type>(B) < Point<real_type>::EPS){ point[0](C / A, 0); point[1](C / A, 1); }
            else{ point[0](0, C / B); point[1](C / A, 0); } 
        }
        // 交差するか判定する : 交差する場合は true
        bool intersect(const Line& other) const {
            const real_type v1_det_v2 = (point[1] - point[0]).determinant(other.point[1] - other.point[0]);
            return not Point<real_type>::isZero(v1_det_v2);
        }
        // 平行か判定する : 交差する場合は true
        bool pararell(const Line& other) const {
            const real_type v1_det_v2 = (point[1] - point[0]).determinant(other.point[1] - other.point[0]);
            return Point<real_type>::isZero(v1_det_v2);
        }
        // 点 P をこの直線上に射影した点を返す (垂線の足)
        Point<real_type> projectionOf(const Point<real_type>& P) const {
            const Point<real_type> v = point[1] - point[0];
            return point[0] + (v * v.dot(P - point[0]) / v.norm());
        }
        // 直線が一致するか判定する
        inline bool operator == (const Line& other) const {
            const Point<real_type> v1 = point[1] - point[0];
            if(not Point<real_type>::isZero( v1.determinant(other.point[1] - other.point[0]))) return false;
            return Point<real_type>::isZero( v1.determinant(other.point[1] - point[0]) );
        }
    };
    // 線分 AB を表すクラス
    template <typename real_type> class LineSegment{
    public:
        std::array<Point<real_type>, 2> point; // 2点

        // コンストラクタ : 点 p1, p2による線分
        constexpr LineSegment( const Point<real_type>& p1, 
                               const Point<real_type>& p2): point({{p1, p2}}){}
        // 線分が交差するか判定する関数 ; 端点で交わる場合, 直線が一致する場合も true を返すことに注意せよ
        constexpr bool intersect(const LineSegment& other) const {
            return (iSP(point[0], point[1], other.point[0]) * iSP(point[0], point[1], other.point[1]) <= 0)
                    and (iSP(other.point[0], other.point[1], point[0]) * iSP(other.point[0], other.point[1], point[1]) <= 0);
        }
        inline bool operator == (const LineSegment& other) const {
            return (point[0] == other.point[0] and point[1] == other.point[1])
                    or (point[0] == other.point[1] and point[1] == other.point[0]);
        }
    };
    // 円を表すクラス
    template <typename real_type> class Circle{
    public:
        real_type radius; // 半径
        Point<real_type> center_point; // 中心
        constexpr Circle( const real_type radius = 0, 
                          const Point<real_type>& point = {}): 
                          radius(radius), center_point(point){}
    };

    #undef EPSILON_VALUE
};

int main(void){
    Geometory::Point<double> A, B; MIO::cin >> A >> B;
    Geometory::Line<double> L(A, B);
    unsigned int n; MIO::cin >> n;
    for(unsigned int i = 0; i < n; ++i){
        Geometory::Point<double> Ptr; MIO::cin >> Ptr;
        MIO::cout << L.projectionOf(Ptr) << '\n';
    }


    return 0;
}


Measured memory_bytes: 3260