import java.io.*;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.util.StringTokenizer;

public class GenPics {

    public static void main(String[] args) throws FileNotFoundException {
        if (args.length == 2) {
            new GenPics(args[0], args[1]).run();
        } else {
            new GenPics("green.in", "green.out").run();
        }
    }

    private void run() throws FileNotFoundException {
        int n = input.nextInt();
        int m = input.nextInt();
        int a = input.nextInt();
        final double[] h = new double[n];
        double[] x = new double[m];
        double[] y = new double[m];
        for (int i = 0; i < n; i++) {
            h[i] = input.nextInt();
        }
        for (int i = 0; i < m; i++) {
            x[i] = input.nextInt();
            y[i] = input.nextInt();
        }
        final double[] pos = new double[n];
        output.nextDouble();
        for (int i = 0; i < n; i++) {
            pos[i] = output.nextDouble();
        }


        PrintWriter out = new PrintWriter("pic.mp");
        out.println("\n" +
                "def drawExample (suffix l, t, n, m, a, b, s) =\n" +
                "  pair sa, sd;\n" +
                "  sa := (cosd a, -sind a);\n" +
                "  sd := (sind a, cosd a);\n" +
                "\n" +
                "  path ll;\n" +
                "  ll := l--((point (length l) of l) shifted (0, 1000));\n" +
                "\n" +
                "  for i := 0 upto m-1:\n" +
                "    pair pb, pz;\n" +
                "    pb := (point i of l) shifted (0,0.1);\n" +
                "    pz := (pb--(pb + 1000sa)) intersectiontimes ll;  \n" +
                "    show pb;\n" +
                "    if (xpart pz > -1):\n" +
                "      pickup pencircle scaled 0.3;\n" +
                "      fill (pb--(subpath(i, ypart pz) of ll)--cycle) scaled un withcolor white * 0.8;\n" +
                "    fi;\n" +
                "  endfor;\n" +
                "\n" +
                "  for i := 1 upto n:\n" +
                "    pair p, q, pa, pb, pz;\n" +
                "    p := t[i];\n" +
                "    x := xpart p;\n" +
                "    show x;\n" +
                "    q := ((x,-3000)--(x, 3000)) intersectiontimes ll;\n" +
                "    pa := point (ypart q) of ll;\n" +
                "    pb := pa shifted (0, ypart p);\n" +
                "    pz := (pb--(pb + 1000sa)) intersectiontimes ll;  \n" +
                "    if (xpart pz > -1):\n" +
                "      pickup pencircle scaled 0.3;\n" +
                "      fill (pb--(subpath(ypart q, ypart pz) of ll)--cycle) scaled un withcolor white * 0.8;\n" +
                "    fi;\n" +
                "    pickup pencircle scaled 1;\n" +
                "    draw (pa--pb) scaled un;                         \n" +
                "  endfor;\n" +
                "\n" +
                "  fill (l{1, -1} .. \n" +
                "     (xpart (point (length l) of l), b) .. \n" +
                "     (xpart (point 0 of l), b) .. {1, 1}cycle) scaled un\n" +
                "     withcolor white * 0.5;\n" +
                "  %fill ((l .. (reverse l shifted (0,-10)) .. cycle) scaled un) withcolor white * 0.3;\n" +
                "\n" +
                "  pickup pencircle scaled 1;\n" +
                "  drawarrow (s .. (s + sa * 10)) scaled un;\n" +
                "  drawarrow ((s .. (s + sa * 10)) shifted 5sd) scaled un;\n" +
                "  drawarrow ((s .. (s + sa * 10)) shifted 10sd) scaled un;\n" +
                "  if (a > 30):\n" +
                "    pickup pencircle scaled 0.3;\n" +
                "    draw ((s + sa * 10)..(s + sa * 10 - (10,0))) scaled un;\n" +
                "    draw ((s + sa * 5)..{down}(s + sa * 10 - (5,0))) scaled un;\n" +
                "    label.top(\"a\", (s + sa * 10 - (10,0)) scaled un);\n" +
                "  fi;\n" +
                "enddef;");

        out.println("beginfig(1)\n" +
                "  un := 0.5mm;\n" +
                "  path l;\n" +
                "  pair t[];\n" +
                "  pair s;\n");


//        double minx = x[0];
//        double miny = y[0];
//
//        minx += 1;
//        miny += 1;
//        for (int i = 0; i < m; i++) {
//            x[i] -= minx;
//            y[i] -= miny;
//        }
//        for (int i = 0; i < n; i++) {
//            pos[i] -= minx;
//        }
//
        normalize(x);
        normalize(y);
        normalize(pos);

        out.println("m := " + m + ";");
        out.print("l := ");
        for (int i = 0; i < m; i++) {
            out.print("(" + x[i] + "," + y[i]+")");
            if (i < m - 1) out.print("--"); else out.println(";");
        }
        out.println("n := " + n + ";");
        Integer[] p = new Integer[n];
        for (int i = 0; i < n; i++) p[i] = i;
        Arrays.sort(p, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return Double.compare(pos[o1], pos[o2]);
            }
        });
        for (int i = 0; i < n; i++) {
            out.println("t[" + (i + 1) + "] := (" + pos[p[i]] + ", " + h[p[i]] + ");");
        }
        out.println("a := " + a + ";");

        double b = y[0];
        for (int i = 0; i < m; i++) b = Math.min(b, y[i]);
        b -= 10;

        out.println("b := " + b + ";");

        double z = y[0];
        for (int i = 0; i < m; i++) z = Math.max(z, y[i]);
        z += 40;

        out.println("s := (" + x[0] + "," + z + ");");
        out.println("drawExample(l, t, n, m, a, b, s);\n" +
                "endfig;\n" +
                "end.");

        out.close();



    }

    private void normalize(double[] x) {
        for (int i = 0; i < x.length; i++) {
            x[i] = Math.round(x[i] * 100) / 100;
        }
    }


    Scanner input;
    Scanner output;

    public GenPics(String input, String output) throws FileNotFoundException {
        this.input = new Scanner(new File(input));
        this.output = new Scanner(new File(output));
    }

}
