public void solve() throws IOException {
    int n = nextInt();
    int[] rows = new int[n];
    int[] cols = new int[n];
    for (int i = 0; i < n; i++) {
      String input = nextLine();
      for (int j = 0; j < n; j++) {
        if (input.charAt(j) == 'C') {
          rows[i]++;
          cols[j]++;
        }
      }
    }
    long total = 0;
    for (int i = 0; i < n; i++) {
      total += rows[i] * (rows[i] - 1) / 2;
      total += cols[i] * (cols[i] - 1) / 2;
    }
    out.println(total);
  }