#region ZIPPER
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using sc = Scanner;
using Geometry;
using gl = Geometry.GeometryLibrary;
class Program
{
    static void Main(string[] args)
    {
        Solver solver = new Solver();
        solver.Solve();
#if DEBUG
        System.Console.WriteLine("?¶?????????????????????????????????????????????????????????????");
        System.Console.ReadKey();
#endif

    }
}
/// <summary>
/// ?¨??????\????????????????????´???????????????????????????????????????
/// </summary>
public static class Scanner
{
    public static string NextString()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return tmp;
    }
    public static int NextInt()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return int.Parse(tmp);
    }
    public static long NextLong()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return long.Parse(tmp);
    }
    public static double NextDouble()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return double.Parse(tmp);
    }

    public static string[] NextStrArray()
    {
        return Console.ReadLine().Split(' ');
    }
    public static int[] NextIntArray()
    {

        string[] s = NextStrArray();
        int[] a = new int[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = int.Parse(s[i]);
        }
        return a;
    }
    public static long[] NextLongArray()
    {
        string[] s = NextStrArray();
        long[] a = new long[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = long.Parse(s[i]);
        }
        return a;
    }
    public static double[] NextDoubleArray()
    {
        string[] s = NextStrArray();
        double[] a = new double[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = double.Parse(s[i]);
        }
        return a;
    }
}
#endregion ZIPPER

public class Solver
{
#region IGNORE_ME
    public Solver()
    {
        //???????????¨?????????????????????????????????????????????
    }
#endregion IGNORE_ME

    public void Solve()
    {
        Point p1 = new Point(sc.NextDouble(), sc.NextDouble());
        Point p2 = new Point(sc.NextDouble(), sc.NextDouble());
        int q = sc.NextInt();
        Point[] p = new Point[q];
        for (int i = 0; i < q; i++)
        {
            p[i] = new Point(sc.NextDouble(), sc.NextDouble());
        }
        for (int i = 0; i < q; i++)
        {
            Point s = gl.Projection(p1, p2, p[i]);
            Console.WriteLine("{0} {1}", s.x, s.y);
        }
#if DEBUG
        Console.WriteLine("");//local check
#endif
    }
}
namespace Geometry
{
    /// <summary>
    /// ??????x,y??§?¨??????¨???
    /// </summary>
    public struct Point
        {
            public double x;
            public double y;
            public Point(int x, int y)
            {
                this.x = (double)x; this.y = (double)y;
            }
            public Point(double x, double y)
            {
                this.x = x; this.y = y;
            }
            public static Point operator +(Point p1, Point p2)
            {
                return new Point(p1.x + p2.x, p1.y + p2.y);
            }
            public static Point operator -(Point p1, Point p2)
            {
                return new Point(p1.x - p2.x, p1.y - p2.y);
            }
            public static Point operator *(double s, Point p)
            {
                return new Point(s * p.x, s * p.y);
            }
        }
    public static class GeometryLibrary
    {


        /// <summary>
        /// ??????
        /// </summary>
        /// <returns></returns>
        public static double Naiseki(Point p1, Point p2)
        {
            return p1.x * p2.x + p1.y * p2.y;
        }
        /// <summary>
        /// ??´???p1,p2???????????????p????°???±
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public static Point Projection(Point p1, Point p2, Point p)
        {
            Point a = p2 - p1;
            Point b = p - p1;
            double t = Naiseki(a, b) / Naiseki(a, a);
            return t * a + p1 ;
        }
    }
}

Measured memory_bytes: 20132