public static void main(String[] argv) {
    Random gen = new Random();
    for (int times = 0; times < 1000; ++times) {
      System.out.println(times);
      ArrayList<String> stream = new ArrayList<String>();
      int n, k;
      if (argv.length == 1) {
        n = Integer.parseInt(argv[0]);        
        k = gen.nextInt(n) + 1;
      } else if (argv.length == 2) {
        n = Integer.parseInt(argv[0]);
        k = Integer.parseInt(argv[1]);
      } else {        
        n = gen.nextInt(99999);        
        k = gen.nextInt(n) + 1;
      }
      for (int i = 0; i < n; ++i) {        
        stream.add(rand_string(gen.nextInt(5) + 1));
      }
      ArrayList<String> items = search_frequent_items(stream, k);
      check_ans(stream, k, items);
    }    
  }