package no30; import java.util.ArrayList; import java.util.Scanner; public class Main { static long[][] memo; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); @SuppressWarnings("unchecked") ArrayList[] recipe = new ArrayList[n]; for(int i=0;i(); } for(int i=0;i[] recipe) { if (memo[i] != null) { return memo[i]; } long[] sum = new long[n]; if (recipe[i].size() == 0) { sum[i] = 1; }else{ for(Pair p:recipe[i]) { long[] m = dfs(p.material,n,recipe); for(int j=0;j