import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int k = sc.nextInt(); ArrayList> graph = new ArrayList<>(); int[] values = new int[n]; for (int i = 0; i < n; i++) { graph.add(new ArrayList<>()); values[i] = sc.nextInt(); int m = sc.nextInt(); for (int j = 0; j < m; j++) { int idx = sc.nextInt() - 1; if (values[idx] < values[i]) { graph.get(idx).add(new Path(i, values[i] - values[idx])); } } } PriorityQueue queue = new PriorityQueue<>(); long[] gains = new long[n]; Arrays.fill(gains, -1); queue.add(new Path(0, 0)); while (queue.size() > 0) { Path p = queue.poll(); if (gains[p.idx] >= p.value) { continue; } gains[p.idx] = p.value; for (Path x : graph.get(p.idx)) { queue.add(new Path(x.idx, x.value + p.value)); } if (p.idx < n - 1) { queue.add(new Path(p.idx + 1, p.value)); } } System.out.println(gains[n - 1]); } static class Path implements Comparable { int idx; long value; public Path(int idx, long value) { this.idx = idx; this.value = value; } public int compareTo(Path another) { if (idx == another.idx) { if (value == another.value) { return 0; } else if (value < another.value) { return 1; } else { return -1; } } else { return idx - another.idx; } } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }