program checkd;

uses
    testlib, sysutils;

const
    maxn = 10;
    maxs = 200;
    maxc = 10;

var
    x, y: array [1..maxn + 1] of longint;
    n: longint;

function inside(xp, yp: longint): boolean;
var
    i: longint;
begin
    inside := false;
    for i := 1 to n do
    begin
        if (x[i] - xp) * (y[i + 1] - yp) - (x[i + 1] - xp) * (y[i] - yp) > 0 then
            exit;
    end;

    inside := true;
end;

function intersect(x1, y1, x2, y2, x3, y3, x4, y4: longint): boolean;
var
    a1, b1, c1, a2, b2, c2, d, xc, yc: longint;
begin
    intersect := false;

    a1 := y2 - y1;
    b1 := x1 - x2;
    c1 := a1 * x1 + b1 * y1;
    a2 := y4 - y3;
    b2 := x3 - x4;
    c2 := a2 * x3 + b2 * y3;

    d := a1 * b2 - a2 * b1;
    if d = 0 then exit;

    x1 := x1 * d;
    y1 := y1 * d;
    x2 := x2 * d;
    y2 := y2 * d;
    x3 := x3 * d;
    y3 := y3 * d;
    x4 := x4 * d;
    y4 := y4 * d;

    xc := c1 * b2 - c2 * b1;
    yc := a1 * c2 - a2 * c1;

    if 
        ((xc <= x1) and (xc <= x2)) or
        ((yc <= y1) and (yc <= y2)) or
        ((xc >= x1) and (xc >= x2)) or
        ((yc >= y1) and (yc >= y2)) or
        ((xc <= x3) and (xc <= x4)) or
        ((yc <= y3) and (yc <= y4)) or
        ((xc >= x3) and (xc >= x4)) or
        ((yc >= y3) and (yc >= y4)) 
    then
        exit;

    intersect := true;
end;

var
    i, j: longint;
    s: longint;
    x1, y1, x2, y2, x3, y3: array [1..maxs] of longint;

begin
    n := inf.readlongint;

    for i := 1 to n do
    begin
        x[i] := inf.readlongint;
        y[i] := inf.readlongint;
    end;
    x[n + 1] := x[1];
    y[n + 1] := y[1];

    i := ouf.readlongint;
    if (i = 0) and ouf.seekeof then
        quit(_wa, 'only 0 in the output file');

    ouf.reset;

    s := 0;
    for i := 1 to n do
        s := s + (x[i + 1] - x[i]) * (y[i] + y[i + 1]);

    if s < 0 then
        quit(_fail, 'not clockwise order in the input');

    for i := 1 to s do
    begin
        if ouf.seekeof then
            quit(_wa, 'not enough triangles');

        x1[i] := ouf.readlongint;
        y1[i] := ouf.readlongint;
        x2[i] := ouf.readlongint;
        y2[i] := ouf.readlongint;
        x3[i] := ouf.readlongint;
        y3[i] := ouf.readlongint;

        if (x1[i] < 0) or (x1[i] > maxc) then
            quit(_wa, 'point''s coordinates are invalid');
        if (y1[i] < 0) or (y1[i] > maxc) then
            quit(_wa, 'point''s coordinates are invalid');
        if (x2[i] < 0) or (x2[i] > maxc) then
            quit(_wa, 'point''s coordinates are invalid');
        if (y2[i] < 0) or (y2[i] > maxc) then
            quit(_wa, 'point''s coordinates are invalid');
        if (x3[i] < 0) or (x3[i] > maxc) then
            quit(_wa, 'point''s coordinates are invalid');
        if (y3[i] < 0) or (y3[i] > maxc) then
            quit(_wa, 'point''s coordinates are invalid');

        if abs((x2[i] - x1[i]) * (y3[i] - y1[i]) -
                (x3[i] - x1[i]) * (y2[i] - y1[i])) <> 1 then
            quit(_wa, 'triangle with square not equal to 1/2 found');

        if not inside(x1[i], y1[i]) then
            quit(_wa, 'triangle is not completely inside polygon');
        if not inside(x2[i], y2[i]) then
            quit(_wa, 'triangle is not completely inside polygon');
        if not inside(x3[i], y3[i]) then
            quit(_wa, 'triangle is not completely inside polygon');
    end;

    if not ouf.seekeof then
        quit(_wa, 'too many triangles');

    for i := 1 to s do
        for j := i + 1 to s do
        begin
            if intersect(x1[i], y1[i], x2[i], y2[i], x1[j], y1[j], x2[j], y2[j]) or
                    intersect(x2[i], y2[i], x3[i], y3[i], x1[j], y1[j], x2[j], y2[j]) or
                    intersect(x3[i], y3[i], x1[i], y1[i], x1[j], y1[j], x2[j], y2[j]) or
                    intersect(x1[i], y1[i], x2[i], y2[i], x2[j], y2[j], x3[j], y3[j]) or
                    intersect(x2[i], y2[i], x3[i], y3[i], x2[j], y2[j], x3[j], y3[j]) or
                    intersect(x3[i], y3[i], x1[i], y1[i], x2[j], y2[j], x3[j], y3[j]) or
                    intersect(x1[i], y1[i], x2[i], y2[i], x3[j], y3[j], x1[j], y1[j]) or
                    intersect(x2[i], y2[i], x3[i], y3[i], x3[j], y3[j], x1[j], y1[j]) or
                    intersect(x3[i], y3[i], x1[i], y1[i], x3[j], y3[j], x1[j], y1[j]) then
                quit(_wa, 'triangles ' + inttostr(i) + ' and ' + inttostr(j) + ' overlap');
        end;

    for i := 1 to s do
        for j := i + 1 to s do
        begin
            if 
                ((x1[i] = x1[j]) and (x2[i] = x2[j]) and (x3[i] = x3[j]) and
                 (y1[i] = y1[j]) and (y2[i] = y2[j]) and (y3[i] = y3[j])) or
                ((x1[i] = x1[j]) and (x2[i] = x3[j]) and (x3[i] = x2[j]) and
                 (y1[i] = y1[j]) and (y2[i] = y3[j]) and (y3[i] = y2[j])) or
                ((x1[i] = x2[j]) and (x2[i] = x1[j]) and (x3[i] = x3[j]) and
                 (y1[i] = y2[j]) and (y2[i] = y1[j]) and (y3[i] = y3[j])) or
                ((x1[i] = x2[j]) and (x2[i] = x3[j]) and (x3[i] = x1[j]) and
                 (y1[i] = y2[j]) and (y2[i] = y3[j]) and (y3[i] = y1[j])) or
                ((x1[i] = x3[j]) and (x2[i] = x1[j]) and (x3[i] = x2[j]) and
                 (y1[i] = y3[j]) and (y2[i] = y1[j]) and (y3[i] = y2[j])) or
                ((x1[i] = x3[j]) and (x2[i] = x2[j]) and (x3[i] = x1[j]) and
                 (y1[i] = y3[j]) and (y2[i] = y2[j]) and (y3[i] = y1[j])) 
            then
                quit(_wa, 'triangles ' + inttostr(i) + ' and ' + inttostr(j) + ' coincide');
        end;

    quit(_ok, '');
end.
