public boolean connected(int p, int q) {
    // TODO
    for(List<Integer> compent: compentList) {
      if (compent.contains(p) && compent.contains(q)) {
        return true;
      }
    }
    return false;
  }