#include "minecraft.h"
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

static const int maxn = 1e5 + 7;
static vector<int> portal;
static vector<pair<int, pair<int, int>>> g;
static vector<int> fortress;
static int n, k, m, f, l, x, y, L;
static int pref[maxn];
static int q1 = 0, q3 = 0;
int find_portals(int l, int r)
{
    q1++;
    if(l<1||r>n||l>r) {
        cout << "Invalid find_portals arguments!" << endl;
        exit(0);
    }
    return pref[r] - pref[l - 1];
}
string throw_eye(pair<int, int> coordinates)
{
    q3++;
    int x2 = coordinates.first;
    int y2 = coordinates.second;
    if(x2>L||x2<1||y2>L||y2<1) {
        cout << "Invalid throw_eye coordinates!" << endl;
        exit(0);
    }
    if (x2 == x && y2 == y)
    {
        return "NONE";
    }
    if (x2 > x)
    {
        if (y2 > y)
        {
            return "SW";
        }
        if (y2 == y)
        {
            return "W";
        }
        if (y2 < y)
        {
            return "NW";
        }
    }
    if (x2 == x)
    {
        if (y2 > y)
        {
            return "S";
        }
        else
        {
            return "N";
        }
    }
    if (x2 < x)
    {
        if (y2 > y)
        {
            return "SE";
        }
        if (y2 == y)
        {
            return "E";
        }
        if (y2 < y)
        {
            return "NE";
        }
    }
}
int main()
{
    cin >> n >> k;

    for (int i = 0; i < k; i++)
    {
        int x;
        cin >> x;
        portal.push_back(x);
        pref[x]++;
    }
    for (int i = 1; i <= n; i++)
    {
        pref[i] += pref[i - 1];
    }
    cin >> m;

    for (int i = 0; i < m; i++)
    {
        int x, y, w;
        cin >> x >> y >> w;
        g.push_back({w, {x, y}});
    }

    cin >> f;

    for (int i = 0; i < f; i++)
    {
        int z;
        cin >> z;
        fortress.push_back(z);
    }
    cin >> L;
    cin >> x >> y;
    vector<int> ans = portals(n, k);
    sort(ans.begin(), ans.end());
    sort(portal.begin(), portal.end());
    if (ans == portal)
    {
        cout << "Correct first part in " << q1 << " queries" << endl;
    }
    else
    {
        cout << "Incorrect first part in " << q1 << " queries" << endl;
    }
    pair<int, int> second = minimal_danger(n, g, portal, fortress);
    cout << "Second part: " << second.first << " " << second.second << endl;
    pair<int, int> cord = find_end_portal(L);
    if (cord.first == x && cord.second == y)
    {
        cout << "Correct third part in " << q3 << " queries" << endl;
    }
    else
    {
        cout << "Incorrect third part in " << q3 << " queries" << endl;
    }
}