#include <stdio.h>
#include <stdlib.h>
#include <string.h>



int is_reachable(int matrix[20][20], int n, int from, int to) {
    // TODO: implement this function
    (void) matrix;
    (void) n;
    (void) from;
    (void) to;
    return 0;
}


int main(void) {
    int n;
    if (scanf("%d", &n) != 1) { return 0; }
    int matrix[20][20] = {{0}};
    char tok[50];
    int from = 0, to = 0, got = 0;
    while (scanf("%49s", tok) == 1) {
        if (strchr(tok, '-') != NULL) {
            int a, b;
            sscanf(tok, "%d-%d", &a, &b);
            matrix[a][b] = 1;
        } else if (got == 0) { from = atoi(tok); got = 1; }
        else { to = atoi(tok); break; }
    }
    printf("%d\n", is_reachable(matrix, n, from, to));
    return 0;
}
