N,K,X = map(int, raw_input().split()) l1 = [0] * N for i in xrange(1, N+1): l1[i-1] = i b=[] a=[] for i in xrange(1, K+1): A,B=raw_input().split() if i