public void solve() throws IOException {
    int n = nextInt();
    List<Integer> prog = new ArrayList<Integer>();
    List<Integer> math = new ArrayList<Integer>();
    List<Integer> pe = new ArrayList<Integer>();
    
    for (int x = 1; x <= n; x++) {
      int type = nextInt();
      switch (type) {
      case 1: prog.add(x); break;
      case 2: math.add(x); break;
      case 3: pe.add(x); break;
      }
    }
    
    int teams = Math.min(Math.min(prog.size(), math.size()), pe.size());
    System.out.println(teams);
    for (int x = 0; x < teams; x++) {
      System.out.println(prog.get(x) + " " + math.get(x) + " " + pe.get(x));
    }
  }