jiahuimbzuai/CoQuIR huggingface dataset:
//  [ruby]
def ok(i, j, _x, _y, _a)
  if _a == 1
    if i < _x 
      return true
    end
   
  elsif _a == 2
    if i >= _x 
      return true
    end

  elsif _a == 3
    if j < _y 
      return true
    end

  elsif _a == 4
    if j >= _y 
      return true
    end
  end

end

w, h, n = gets.chomp.split(" ").map{|i| i.to_i}
x, y, a = Array.new(3){Array.new(n)}
for i in 0...n
  x[i], y[i], a[i] = gets.chomp.split(" ").map{|i| i.to_i}
end

field = Array.new(w){Array.new(h){false}}

for k in 0...n
  for i in 0...w
    for j in 0...h
      if ok(i, j, x[k], y[k], a[k])
        field[i][j] = true
      end
    end
  end
  #p field
end

s = 0

for i in 0...w
  for j in 0...h
    unless field[i][j] then
      s = s + 1
    end
 end
end

p s
//  [ruby]
def ok(i, j, _x, _y, _a)
  if _a == 1
    i < _x
  elsif _a == 2
    i >= _x
  elsif _a == 3
    j < _y
  elsif _a == 4
    j >= _y
  end
end

w, h, n = gets.chomp.split(" ").map{|i| i.to_i}
x = Array.new(n)
y = Array.new(n)
a = Array.new(n)
for i in 0...n
  x[i], y[i], a[i] = gets.chomp.split(" ").map{|i| i.to_i}  
end

field = Array.new(w){Array.new(h){false}}

for k in 0...n
  for i in 0...w
    for j in 0...h
      if ok(i, j, x[k], y[k], a[k])
        field[i][j] = true
      end
    end
  end
end

ans = 0

for i in 0...w
  for j in 0...h
    if !field[i][j]
      ans += 1
    end
  end
end

puts ans
//  [ruby]
w, h, n = gets.chomp.split(" ").map{|i| i.to_i}
x, y, a = Array.new(3){Array.new(n)}
for i in 0...n
    x[i], y[i], a[i] = gets.chomp.split(" ").map{|i| i.to_i}
end

field = Array.new(w){Array.new(h){false}}

def ok(i, j, _x, _y, a)
  case a
  when 1
    if i < _x
      true
    else
      false
    end
  when 2
    if i >= _x 
      true
    else
      false
    end
  when 3
    if j < _y
      true
    else
      false
    end
  when 4
    if j >= _y
      true
    else
      false
    end
  end
end

for k in 0...n
  for i in 0...w
    for j in 0...h
      if ok(i, j, x[k], y[k], a[k])
        field[i][j] = true
      end
    end
  end
end

ans = 0
for i in 0...w
  for j in 0...h
    if field[i][h-1-j]
      #print "x"
    else
      #print "."
      ans += 1
    end
  end
  #print "\n"
end
puts ans
//  [rust]
use whiteread::parse_line;

fn main() {
    let (w, h, n): (usize, usize, usize) = parse_line().unwrap();

    let mut is_white: Vec<Vec<bool>> = vec![];
    for _ in 0..w {
        let mut v = vec![];
        for _ in 0..h {
            v.push(true);
        }
        is_white.push(v);
    }
    for _ in 0..n {
        let (x, y, a): (usize, usize, usize) = parse_line().unwrap();
        let (x_range, y_range) = match a {
            1 => (0..x, 0..h),
            2 => (x..w, 0..h),
            3 => (0..w, 0..y),
            4 => (0..w, y..h),
            _ => unreachable!(),
        };

        for i in x_range {
            for j in y_range.clone() {
                is_white[i][j] = false;
            }
        }
    }

    let mut ret = 0;
    for i in 0..w {
        for j in 0..h {
            if is_white[i][j] {
                ret += 1;
            }
        }
    }

    println!("{}", ret);
}
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [W, H, N] = input[0].map(Number);

  let top = H;
  let bottom = 0;
  let left = 0;
  let right = W;

  for (let i = 1; i <= N; i++) {
    const [x, y, a] = input[i].map(Number);

    switch (a) {
      case 1: {
        left = Math.max(x, left);
        break;
      }
      case 2: {
        right = Math.min(x, right);
        break;
      }
      case 3: {
        bottom = Math.max(y, bottom);
        break;
      }
      case 4: {
        top = Math.min(y, top);
        break;
      }
    }
  }

  const height = Math.max(0, top - bottom);
  const width = Math.max(0, right - left);

  return height * width;
};

console.log(main(read()));
//  [typescript]
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const [w, h, n] = args[0].map(x => parseInt(x));

let [low_x, high_x] = [0, w];
let [low_y, high_y] = [0, h];

for (let i = 0; i < n; i++) {
    const [x, y, a] = args[i + 1].map(x => parseInt(x));
    switch (a) {
        case 1:
            low_x = Math.max(low_x, x);
            break
        case 2:
            high_x = Math.min(high_x, x);
            break
        case 3:
            low_y = Math.max(low_y, y);
            break
        case 4:
            high_y = Math.min(high_y, y);
            break
    }
}

const lx = high_x - low_x;
const ly = high_y - low_y;

const cnt = (lx > 0 && ly > 0) ? lx * ly : 0;

console.log(cnt);
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let [w,h,n]=tnn(3)
  let ar=new Array(h)
  let x=0,y=0
  for(let i=0;i<h;i++){
    ar[i]=new Array(w)
    ar[i].fill(0)
  }
  for(let i=0;i<n;i++){
    let [xi,yi,a]=tnn(3)
    if(a==1){
      for(let j=0;j<h;j++){
        for(let k=0;k<xi;k++){
          ar[j][k]=1
        }
      }
    }else if(a==2){
      for(let j=0;j<h;j++){
        for(let k=xi;k<w;k++){
          ar[j][k]=1
        }
      }
    }else if(a==3){
      for(let j=0;j<w;j++){
        for(let k=0;k<yi;k++){
          ar[k][j]=1
        }
      }
    }else if(a==4){
      for(let j=0;j<w;j++){
        for(let k=yi;k<h;k++){
          ar[k][j]=1
        }
      }
    }
  }
  let c=0
  for(let i=0;i<h;i++){
    for(let j=0;j<w;j++){
      if(ar[i][j]==0)c++
    }
  }
  to(c)
}
main()
//  [python]
import numpy as np
from collections import defaultdict
from functools import reduce

S = input()

for s in S:
    if S.count(s) != 2:
        break
else:
    print("Yes")
    exit()
print("No")
exit()
//  [python]
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    S = input()
    num_dicts = {}
    for i in range(len(S)):
        if S[i] not in num_dicts:
            num_dicts[S[i]] = 1
        else:
            num_dicts[S[i]] += 1
    for key_, value_ in num_dicts.items():
        if value_ == 2:
            pass
        else:
            print("No")
            sys.exit()
    else:
        if len(num_dicts) == 2:
            print("Yes")
            sys.exit()
        else:
            print("No")
            sys.exit()


if __name__ == '__main__':
    main()
//  [python]
import sys
import numpy as np
sys.setrecursionlimit(1000000)
 
s = input()

s0 = s[0]
s1 = s[1]
s2 = s[2]
s3 = s[3]

if s0 == s1 and s2 == s3 and not s0 == s2:
    print("Yes")
    exit()
if s0 == s2 and s1 == s3 and not s0 == s1:
    print("Yes")
    exit()
if s0 == s3 and s1 == s2 and not s0 == s1:
    print("Yes")
    exit()
print("No")
//  [java]
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.Stream;
import java.util.Map;
import java.util.Collection;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            Map<Character, Integer> map = new HashMap<>();
            for (char c : S.toCharArray()) {
                map.put(c, map.getOrDefault(c, 0) + 1);
            }
            String ret = "No";
            if (map.entrySet().stream().filter(e -> e.getValue() == 2).count() == 2) {
                ret = "Yes";
            }
            out.println(ret);
        }

    }
}
//  [java]

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String line = in.next();
        final Map<Character, Integer> map = new HashMap<>();

        for (char c : line.toCharArray()) {
            map.compute(c, (character, integer) -> {
                final int result;
                if (integer == null) {
                    result = 1;
                } else {
                    result = integer + 1;
                }
                return result;
            });
        }

        if (map.keySet().size() != 2) {
            System.out.println("No");
            return;
        }

        if (map.values().stream().anyMatch(i -> i != 2)) {
            System.out.println("No");
            return;
        }

        System.out.println("Yes");
    }
}
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final String str = s.next();

			if(str.chars().sorted().distinct().count() != 2) {
				System.out.println("No");
				return;
			}

			if(str.chars().filter(c -> c == str.charAt(0)).count() != 2) {
				System.out.println("No");
				return;
			}

			System.out.println("Yes");
		}
	}
}
//  [cpp]
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  string S;
  cin >> S;

  vector<int> count(256);
  for (int i = 0; i < S.size(); i++) count[(int)S[i]]++;
  int num = 0;
  for (int i = 0; i < count.size(); i++) {
    if (count[i] == 0) continue;
    else if (count[i] == 2) num++;
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  if (num == 2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}
//  [cpp]
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    string s;
    cin >> s;
    if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]){
        cout << "Yes" << endl;
    }
    else if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]){
        cout << "Yes" << endl;
    }
    else if(s[0]==s[3] && s[1]==s[2] && s[0]!=s[1]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}
//  [cpp]
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

long long plusL[100000];
long long plusR[100000];
long long minusL[100000];
long long minusR[100000];
long long a[100000];

int main()
{
	string s;
	cin >> s;
	vector<char> data;

	for (int i = 0; i < s.size(); i++)
	{
		data.push_back(s[i]);
	}
	sort(s.begin(), s.end());
	cout << (s[0] == s[1] && s[2] == s[3] && s[1] != s[2] ? "Yes" : "No");
}
//  [c]
#include <stdio.h>



//文字は''でその者と比較できる。
int main()
{

	char mozi[5];
	int i = 0;
	int q, p = 0;
	int j, t;


	scanf("%s", mozi);

	for (i = 0; mozi[i] != '\0'; ++i);

	for (j = 3; j >= 0; j--)
	{

		for (t = 0; t < j; t++)
		{
			if (mozi[j] == mozi[t])
			{
				p++;
			}
		}
	}

	if (p == 2&& i == 4)
	{
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
int main()
{
	char s[4];
	int i,a,c=0,x=0;
	scanf("%s",s);
	a=strlen(s);
	for(i=0;i<a-1;i++){
		for(int j=i+1;j<a;j++){
			if(s[i]==s[j]) c++;
		}
	}
	if(c==2) printf("Yes\n");
	else printf("No\n");
	return 0;
}
//  [c]
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define BUFSIZE 1000000




int main(void){
char s[BUFSIZE];
scanf("%s",s);
int cnt =0 ;
char rem;

for(int i = 0 ;i < 4;i++){
  for(int j = 0;j < 4;j++){
    if(i == j)  break;
    if(s[i] == s[j]){
    if(s[i] == rem){
      printf("No");
      exit(0);
    }
      cnt++;
      rem = s[i];
      break;
    }

  }

}

if(cnt == 2) printf("Yes");
else printf("No");

return 0;



}
//  [javascript]
'use strict'

const main = (INPUT) => {
  const S = INPUT.split('\n')[0].split('')
  const ary = S.filter((x, i, self) => self.indexOf(x) === i)
  if (ary.length == 2) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    const set = new Set(S);
    const unique = [...set];
    
    if(set.size !== 2) {
        console.log("No");
        return;
    }
    
    for(let i in unique) {
        if(S.filter(n=>n===unique[i]).length !== 2) {
            console.log("No");
            return;
        }
    }
    
    console.log("Yes");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]

function Main(input) {
    var S = input.toString();
    var s1 = S.charAt(0);
    var s2 = S.charAt(1);
    var s3 = S.charAt(2);
    var s4 = S.charAt(3);

    if (s1 === s2) {
        if (s1 !== s3 && s3 === s4) {
            console.log('Yes');
        } else {
            console.log('No');
        }
    } else if (s1 === s3) {
        if (s1 !== s2 && s2 === s4) {
            console.log('Yes');
        } else {
            console.log('No');
        }
    } else if (s1 === s4) {
        if (s1 !== s2 && s2 === s3) {
            console.log('Yes');
        } else {
            console.log('No');
        }
    } else {
        console.log('No');
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));
//  [go]
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)
 
func run() {

	var S string;
    S = next();
	solve(S);

}

func solve(S string){

	if len(strings.Replace(S, S[0:1], "", -1)) == 0 {
		Println("No")
		return
	}

	if len(strings.Replace(strings.Replace(S, S[0:1], "", 2), strings.Replace(S, S[0:1], "", 2)[0:1], "", 2)) == 0 {
		Println("Yes")
	}else {
		Println("No")
	}
}


// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}


type IntHeap []int
func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

/////数字と文字
// 基本クラス
type NS struct {
    Num int
    Str string
}

//////　数字と数字
// 基本クラス
type NN struct {
    Num1 int
    Num2 int
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var s string
	fmt.Scan(&s)

	m := map[uint8]int{}

	for i:=0; i<4; i++ {
		m[s[i]] += 1
	}

	for _,v := range m {
		if v != 2 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")

}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	mapa := map[int]int{}
	s := nextStr()
	for _, v := range s {
		mapa[int(v)]++
	}

	if len(mapa) != 2 {
		fmt.Println("No")
		return
	}
	for _, va := range mapa {
		if va != 2 {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
	return
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
func nextIntMat(a int, b int) [][]int {
	mat := make([][]int, a)
	for i := 0; i < a; i++ {
		mat[i] = make([]int, b)
		for j := 0; j < b; j++ {
			mat[i][j] = nextInt()
		}
	}
	return mat
}
//  [ruby]
S = gets.chomp.split(//).sort
puts S[0]==S[1] && S[1]!=S[2] && S[2]==S[3] ? "Yes" : "No"
//  [ruby]
s = gets.chomp
u = s.chars.uniq
if u.size != 2
  puts :No
else
  puts (s.count(u[0]) == 2 && s.count(u[1]) == 2) ? :Yes: :No
end
//  [ruby]
s=gets.chop.split("")
s.sort!
if s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]
  puts :Yes
else
  puts :No
end
//  [rust]
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(s: String);

    let mut v = s.into_bytes();
    v.sort();

    if v[0] == v[1] && v[2] == v[3] && v[0] != v[2] {
        println!("{}", "Yes");
        return;
    }

    println!("{}", "No");
}
//  [rust]
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    if s.iter().cloned().collect::<HashSet<_>>().len() != 2 {
        println!("No");
        return;
    }
    if s.iter().filter(|&&x| x == s[0]).count() == 2 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
//  [rust]
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};

fn main() {
    input! {
        s: String,
    };

    let sc: Vec<char> = s.chars().collect();

    for i in 0..sc.len() {
        if sc.iter().filter(|&x| *x == sc[i]).count() != 2 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}
//  [swift]
let S  = readLine()!
let C = Array(S.characters)

var count = [Character: Int]()

for c in C{
  if (count[c] == nil){
    count[c] = 1
  }
  else{
    if let a = count[c]{
    	count[c] = a + 1
    }
  }
}

var ans = "Yes"
for i in count.values {
  if i != 2 {
    ans = "No"
  }
}

if count.count != 2 {
  ans = "No"
}

print(ans)
//  [swift]
let arr=readLine()!.characters.split{$0==" "}.map{String($0)}
var myDictionary: [Character: Int]  = [:]

var o = "No"
var count = 0

for ch in arr[0].characters {
  if( myDictionary[ch]  == nil ) {
  	myDictionary[ch] = 0
  } else {
    myDictionary[ch]! += 1
    if( myDictionary[ch]! > 2 ) {
      count = 1
    }
  }
}

if( ( myDictionary.count == 2 )  && ( count != 1 )) {
	o = "Yes"
}

print( o )
//  [swift]
let S = readLine()!
var dic = [Character: Int]()
for c in S.characters {
    dic[c] = (dic[c] ?? 0) + 1
}
print(dic.values.sort().first == 2 ? "Yes" : "No")
//  [typescript]
import { stringLiteral } from "@babel/types"

// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { S: string } => {
  const S = lines[0]
  const obj = { S }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { S } = parseLines(lines)
  const initialValue :{ [index:string] : number } = {}
  const result = S.split('').reduce((prev, current): { [index: string]: number } => {
    if (!prev[current]) {
      prev[current] = 1
    } else {
      prev[current] += 1
    }
    return prev
  }, initialValue)

  return Object.keys(result).some(key => result[key] !== 2) ? 'No' : 'Yes'
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}
//  [typescript]
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const s: string[] = input[0].split('').sort();

if(s[0] === s[1] && s[1] !== s[2] && s[2] === s[3]){
    console.log('Yes');
}else{
    console.log('No');
}
//  [typescript]
process.stdin.on('data', (chunk: any) => {
  return main(normalize(chunk));
});

function main(S: string) {
  const chars = S.split('');

  // NOTE: 文字列が2種類であることを確認する
  const types = chars.filter((val, i, self) => self.indexOf(val) === i);
  if (types.length !== 2) {
    console.log('No');
    return;
  }

  // NOTE: 指定したtypeが、文字列Sにいくつ含まれるかを確認する
  const check = (type: string): number => {
    const regex = new RegExp(type, 'g');
    const matchedList = S.match(regex);
    return matchedList ? matchedList.length : 0;
  };

  console.log(types.every(type => check(type) === 2) ? 'Yes' : 'No');
}

function normalize(input: any): string {
  return input
    .toString()
    .replace('\n', '')
    .replace(' ', '');
}
//  [python]
n = int(input())
t = []
for i in range(677):
    t.append([])
x = n
for i in range(n):
    a = input()
    if(len(a) < 4):
        if(a in t[0]):
            x -= 1
        else:
            t[0].append(a)
    else:
        p = ord(a[0])*26+ord(a[1])-2618
        if(a[2:] in t[p]):
            x -= 1
        else:
            t[p].append(a[2:])
print(x)
//  [python]
import numpy as np
N=int(input())
S_list = np.zeros(N)
#S_list = np.zeros(N,dtype=str)
e_list = "abcdefghijklmnopqrstuvwxyz"

for i in range(N):
  s = input()
  n = 0
  for k in range(len(s)):
    n = n + (e_list.index(s[k])+1)*(100**k)
  S_list[i] = n
print(len(np.unique(S_list)))
//  [python]
from pip._vendor.distlib.compat import raw_input

n = int(raw_input())
items = set()
for i in range(n):
    items.add(raw_input())
print(len(items))
//  [java]
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		ArrayList<String> array = new ArrayList<String>();

		while(sc.hasNext()) {
			String s = sc.next();
			int index = Collections.binarySearch(array, s);
			if(index < 0) {
				index = - (index + 1);
				array.add(index, s);
			}
		}

		int ans = array.size();

		System.out.println(ans);

		sc.close();

	}

}
//  [java]
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        int n = Integer.parseInt(str);
        String[] sss = new String[n];
        int nums = 1;
        for (int i = 1; i <= n; i++){
            sss[i - 1] = lines[i];
        }     
        Arrays.sort(sss);
        for (int j = 1; j <= n - 1; j++){
            if(!(sss[j-1].equals(sss[j]))){
                nums++;
            }
        }
        System.out.println(nums);
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

int main(){
	int N;
	cin >> N;
	int Size = ceil(sqrt(N));
	vector<string> table[Size];
	int sum = 0;
	while(N-- > 0){
        string S;
        cin >> S;

        int temp = 0;
        for(int a = 0; a < S.size(); a++){
            temp += S[a] - 'a' + 1;
            temp *= 26;
            temp %= Size;
        }

        int found = false;
        for(int a = 0; a < table[temp].size(); a++){
            if(S.compare(table[temp][a]) == 0){
                found = true;
                break;
            }
        }

        if(!found){
            sum++;
            table[temp].push_back(S);
        }
	}

	cout << sum << endl;
	return 0;
}
//  [cpp]
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main(void)
{
    // Your code here!
    int N;
    cin >> N;
    int cnt = 0;
    std::vector<long> S = {0};
    for (int i = 0; i < N; i++)
    {
        string tmp;
        cin >> tmp;
        long keta = 1;
        long sum = 0;
        for (int j = 0; j < tmp.size(); j++)
        {
            keta = pow(26, j);
            sum += (tmp[j] - ('a' - 1)) * keta;
        }

        //cout << sum << endl;
        auto it = lower_bound(S.begin(), S.end(), sum);
        if (*it != sum)
        {
            S.insert(it, sum);
            cnt++;
        }
    }
    cout << S.size() - 1 << endl;
}
//  [cpp]
#include <iostream>
#include <unordered_map>
#include <iterator>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  vector<size_t> v(20000);
  int sum = 0;

  unordered_map<size_t, int> um;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    size_t hs = hash<string>()(str);
    auto itr = lower_bound(v.begin(), v.end(), hs);

    if (itr == v.end()) {
      v.push_back(hs);
      sum++;
    } else if (*itr != hs) {
     v.insert(itr, hs);
      sum++;
    } else {
    }
  }
  cout << sum << endl;

  return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

struct list{
  char name[15];
  struct list *next;
};

struct list *talloc(){
  return (struct list *)malloc(sizeof(struct list));
}

char a[200007][14];
struct list *data[256000];

int main(){
  int n;
  int i,r,j;
  int ans = 0;
  long long sum = 0;
  int flag = 0;
  struct list *p,*t;

  scanf("%d", &n);

  for(i = 0;i <= 255999;i++) data[i] = NULL;

  for(i = 0;i < n;i++){
    scanf("%s", a[i]);
    flag = 0;
    sum = 0;
    r = strlen(a[i]);
    for(j = 0;j < r;j++){
      sum += a[i][j]*(j + 1);
    }

    sum = sum % 256000;

    t = data[sum];
    while(t != NULL){
      if(strcmp(t -> name,a[i]) == 0){
        flag = 1;
        break;
      }
      t = t -> next;
    }

    if(flag == 1) continue;

    else if(flag == 0){
      p = talloc();
      strcpy(p -> name,a[i]);
      p -> next = data[sum];
      data[sum] = p;
      ans++;
    }
  }

  printf("%d\n", ans);

  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

char item[200005][15];

void mergsort(int l, int r) {
    if (r - l <= 0) return;
    int mid = l + (r - l >> 1);
    mergsort(l, mid);
    mergsort(mid + 1, r);
    char a[r + 1][15];
    int tl = l, tr = mid + 1;
    for (int i = l; i <= r; i++) {
        memset(a[i], 0, 15);
        if (tl != mid + 1 && (tr == r + 1 || strcmp(item[tl], item[tr]) <= 0)) {
            for (int j = 0; j < strlen(item[tl]); j++)
                a[i][j] = item[tl][j];
            tl++;
        }
        else {
            for (int j = 0; j < strlen(item[tr]); j++)
                a[i][j] = item[tr][j];
            tr++;
        }
    }
    for (int i = l; i <= r; i++) {
        memset(item[i], 0, 15);
        for (int j = 0; j < strlen(a[i]); j++)
            item[i][j] = a[i][j];
    }
    return;
}

int main() {
    int n; scanf("%d", &n);
    int cnt = 0;
    for (int i = 0; i < n; i++)
        scanf("%s", item[i]);
    mergsort(0, n - 1);
    for (int i = 1; i < n; i++)
        if (strcmp(item[i], item[i - 1]) != 0) cnt++;
    printf("%d\n", cnt + 1);
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

struct cell{
	struct cell *next[30];
	int e;
};

int main(void){
	int n,i,s,c,changed,j;
	
	struct cell head;
	struct cell *p;
	
	for(i=0;i<30;i++)
	 head.next[i]=NULL;
	head.e=0;
	
	s=0;
	
	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++){
	 p=&head;
		changed=0;
	 while((c = getchar()) != '\n'){
	 	if(p->next[c-'a']==NULL){
	 		changed=1;
	 		p->next[c-'a']=(struct cell *)malloc(sizeof(struct cell));
	 		p=p->next[c-'a'];
	 		for(j=0;j<30;j++)
	 		p->next[j]=NULL;
	 		p->e=0;
	 		//printf("m");
	 	}
	 	else{
	 	 p=p->next[c-'a'];
	 		//printf("else");
	 	}
	 }
		if(p->e == 0){p->e=1; changed=1;}
	 s+=changed;
	}
	
	printf("%d\n",s);
	
	return 0;
}
//  [javascript]
function main(input) {
  const result = input.trim().split('\n');
  const answer = new Set(result.slice(1));
  console.log(answer.size);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input) {
  const inputs = input.split('\n')
  const ss = inputs.slice(1)
  const r = {}
  ss.forEach(e => {
    r[e] = 1
  })
  // console.log(Object.keys(r))
  console.log(Object.keys(r).length)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())
//  [javascript]
function Scanner(input) {
	var self = this;
	self.itemNo = 0;
	self.orgStr = input;
	self.splitedStrs = (function(target) {
		var result = [];
		var target = target.replace(/[\n \t]+/g, " ");
		var strs = target.split(" ");
		for (var i = 0, len = strs.length; i < len; i++) {
			result.push(strs[i]);
		}
		return result;
	}(input));

	self.next = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? result : null;
	}

	self.nextInt = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseInt(result) : null;
	}

	self.nextBigDecimal = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseFloat(result) : null;
	}
	
	self.nextByte = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? new Int8Array(result) : null;
	}

}

function Main(sc) {

	var N = sc.nextInt();
	
	var przs = {};
	var cnt = 0;
	for (var i = 0; i < N; i++) {
		var prz = sc.next();
		if (!przs[prz]) {
			przs[prz] = true;
			cnt++;
		}
	}
	 
	console.log(cnt);
}
Main(new Scanner(require("fs").readFileSync("/dev/stdin", "utf8")));
// Main(new Scanner("10 1 2 5 3 4 6 7 3 2 4 1 2 2 3 3 4 4 5 3 6 6 7 1 8 8 9 9 10"));

// var str1 = sc.next(); // Stringで取得
// var int1 = sc.nextInt(); // intで取得
// var bd1 = sc.nextBigDecimal(); // BigDecimalで取得
// var byte1 = sc.nextByte(); // byteで取得
// for (var i = 0; i < 1000000000; i++) var toDelay = "aaa"; // 1000msくらいの遅延
// console.log(wrtnNos); return;
//  [go]
package main

import (
	"fmt"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	S := make([]string, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%s", &S[i])
	}

	m := make(map[string]bool)
	uniq := []string{}

	for _, ele := range S {
		if !m[ele] {
			m[ele] = true
			uniq = append(uniq, ele)
		}
	}

	fmt.Println(len(uniq))
}
//  [go]
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	m := make(map[string]int)
	for i := 0; i < N; i++ {
		var s string
		fmt.Scan(&s)
		m[s]++
	}
	fmt.Println(len(m))
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	answer := countItems(n)
	fmt.Println(answer)
}

func countItems(n int) int {
	var s string
	itemMap := make(map[string]int)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &s)
		itemMap[s]++
	}
	return len(itemMap)
}
//  [ruby]
n=gets.to_i
s=Array.new(n)
for i in 0..n-1
  s[i]=gets.split
end
s.sort!
same=0
for j in 0..n-2
  if s[j]==s[j+1]
    same+=1
  end
end
puts n-same
//  [ruby]
a = gets.chomp.to_i
b = []
a.times do
  b << gets.chomp.split.to_s
end

puts b.each_with_object(Hash.new(0)){|v,o| o[v]+=1}.length
//  [ruby]
N = gets.chomp.to_i

counter = Hash.new(0)

N.times do
  item = gets.chomp.split
  counter[item] += 1
end

print counter.length.to_i
//  [rust]
const NUM_OF_AB :usize = 26;
const A_INDEX   :usize = 97;

struct Category {
    //depth    :u32,
    children    :Vec<Category>,
    list        :Vec<String>,
    active_bmp  :u32,
}
impl Category {
    //fn new(depth :u32) -> Category
    fn new() -> Category
    {
        Category {
            //depth:    depth,
            children:   Vec::new(),
            list:       Vec::new(),
            active_bmp: 0,
        }
    }

    fn prepare(&mut self)
    {
        for _ in 0..NUM_OF_AB {
            self.children.push(Category::new());
        }
    }

    fn is_active(&self, key1 :usize, _key2 :usize) -> bool
    {
        let mut ret = false;
        if  (self.active_bmp & (1<<key1)) != 0  {
            //if  (self.children[key1].active_bmp & (1<<key2)) != 0  {
                ret = true;
            //}
        }
        ret
    }

    fn activate(&mut self, key1 :usize, _key2 :usize)
    {
        if  (self.active_bmp & (1<<key1)) == 0  {
            self.children[key1].prepare();
            self.active_bmp |= {1<<key1};
        }
        //println!("len = {}", self.children[key1].children[key2].list.len());
    }

    fn search(&self, word :&String) -> bool
    {
        let mut ret = false;
        for i in 0..self.list.len() {
            if  *word == self.list[i]  {
                ret = true;
                break;
            }
        }
        ret
    }

    fn push(&mut self, word :String)
    {
        self.list.push(word);
    }

    fn num_of_nodes(&self) -> u32
    {
        let mut total :u32 = 0;
        for frst in 0..NUM_OF_AB {
            for scnd in 0..NUM_OF_AB {
                if  self.is_active(frst, scnd)  {
                    total += {self.children[frst].children[scnd].list.len() as u32};
                }
            }
        }
        total
    }
}

fn index_get(c :char) -> usize
{
    let code = c as usize;
    if  code > A_INDEX  {
        code - A_INDEX
    } else {
        0
    }
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();

    let mut prize :Category = Category::new();
    prize.prepare();

    let num_of_prizes :usize = s.trim().parse::<usize>().ok().unwrap();

    for _ in 0..num_of_prizes {
        let mut s1 = String::new();
        std::io::stdin().read_line(&mut s1).ok();

        let mut si = s1.chars();
        let frst = index_get(si.next().unwrap());
        let scnd =
            match  si.next()  {
                None    => 0,
                Some(c) => index_get(c),
            };
        if  !prize.is_active(frst, scnd)  {
            prize.activate(frst, scnd);
        }
        if  !prize.children[frst].children[scnd].search(&s1)  {
            prize.children[frst].children[scnd].push(s1);
        }
    }

    println!("{}", prize.num_of_nodes());
}
//  [rust]
use text_io::*;
use std::process::exit;
use im_rc::HashMap;

fn main(){
    let mut n:isize = read!();
    let mut map= HashMap::new();
    let mut sum:usize = 0;
    for i in 0..n {
        let mut s:String = read!();
        let mut t: &i32 = map.get(&s).unwrap_or(&0);
        let mut o: &i32 = &0;
        if t == o {
            map.insert(String::from(s),1);
            sum += 1;
        }
    }
    println!("{}",sum);
}
//  [rust]
const NUM_OF_AB :usize = 26;
const A_INDEX   :usize = 97;

struct Category {
    //depth    :u32,
    children    :Vec<Category>,
    list        :Vec<String>,
    active_bmp  :u32,
}
impl Category {
    //fn new(depth :u32) -> Category
    fn new() -> Category
    {
        Category {
            //depth:    depth,
            children:   Vec::new(),
            list:       Vec::new(),
            active_bmp: 0,
        }
    }

    fn prepare(&mut self)
    {
        for _ in 0..NUM_OF_AB {
            self.children.push(Category::new());
        }
    }

    fn is_active(&self, key1 :usize, _key2 :usize) -> bool
    {
        let mut ret = false;
        if  (self.active_bmp & (1<<key1)) != 0  {
            //if  (self.children[key1].active_bmp & (1<<key2)) != 0  {
                ret = true;
            //}
        }
        ret
    }

    fn activate(&mut self, key1 :usize, _key2 :usize)
    {
        if  (self.active_bmp & (1<<key1)) == 0  {
            self.children[key1].prepare();
            self.active_bmp |= {1<<key1};
        }
        //println!("len = {}", self.children[key1].children[key2].list.len());
    }

    fn search(&self, word :&String) -> bool
    {
        let mut ret = false;
        for i in 0..self.list.len() {
            if  *word == self.list[i]  {
                ret = true;
                break;
            }
        }
        ret
    }

    fn push(&mut self, word :String)
    {
        self.list.push(word);
    }

    fn num_of_nodes(&self) -> u32
    {
        let mut total :u32 = 0;
        for frst in 0..NUM_OF_AB {
            for scnd in 0..NUM_OF_AB {
                if  self.is_active(frst, scnd)  {
                    total += {self.children[frst].children[scnd].list.len() as u32};
                }
            }
        }
        total
    }
}

fn index_get(c :char) -> usize
{
    let code = c as usize;
    if  code >= A_INDEX  {
        code - A_INDEX
    } else {
        NUM_OF_AB
    }
}

fn second_key_get(mut si :std::str::Chars, key1: usize) -> usize
{
    let mut key2 = key1;
    while  key2 == key1  {
        let key_n =
            match  si.next()  {
                None    => NUM_OF_AB,
                Some(c) => index_get(c),
                //Some(c) => 0,
            };
        if  key_n == NUM_OF_AB  {
            break;
        } else {
            key2 = key_n;
        }
    }
    key2
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();

    let mut prize :Category = Category::new();
    prize.prepare();

    let num_of_prizes :usize = s.trim().parse::<usize>().ok().unwrap();

    for _ in 0..num_of_prizes {
        let mut s1 = String::new();
        std::io::stdin().read_line(&mut s1).ok();
        //println!("{}", s1);

        let mut si = s1.chars();
        let frst = index_get(si.next().unwrap());
        let scnd = second_key_get(si, frst);
        if  !prize.is_active(frst, scnd)  {
            prize.activate(frst, scnd);
        }
        if  !prize.children[frst].children[scnd].search(&s1)  {
            prize.children[frst].children[scnd].push(s1);
        }
    }

    println!("{}", prize.num_of_nodes());
}
//  [swift]
import Foundation

func readInts() -> [Int]{
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main(){
    let count = Int(readLine()!)!
    var ary: Set = Set<String>()
    for _ in 1...count {
        ary.insert(readLine()!)
    }
    print(ary.count)
}
main()
//  [swift]
let num = Int(readLine()!)!
   
    var arrSet = Set<String>()
    
    for i in 0 ..< num {
       let str = readLine()!
      arrSet.insert(str)
    }
    
    print(arrSet.count)
//  [typescript]
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const n = Number(inputs[0]);
  let hitList: { [key: string]: number } = {};

  for (let i = 1; i <= n; i++) {
    let str = inputs[i];
    if (!(str in hitList)) {
      hitList[str] = 1;
    }
  }

  console.log(Object.keys(hitList).length);
}
//  [typescript]
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!
 
const Main = (p)=>{
	// 1行目がinput[0], 2行目がinput[1], …に入る
	p = p.split("\n");
	let N = parseInt(p[0]);
	let kehin=[];
	for(let i=0;i<N;i++){
	    kehin[p[i+1]]=1;
	}
	//文字列から10進数に変換するときはparseIntを使います
	//出力
	console.log(Object.keys(kehin).length);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n:number):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n:number):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop:number, callback:any){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const m = () => {
  const o = new AtCoder()
  let n=o.n(),obj={}
  for(let i=0;i<n;i++){
    obj[o.s()] = 1;
  }
  o.o(Object.keys(obj).length)
}
m();
//  [python]
def main():
    H, W, K = map(int, input().split())
    mapping = [input() for _ in range(H)]

    count = 0
    ans = []
    is_find_first_ichigo = False
    tmp = ""
    num = 0
    for i, line in enumerate(mapping):
        if "#" in line:
            num += 1
            is_find_first_ichigo = True
            first_ichigo = True
            tmp = []
            for c in line:
                if c == ".":
                    tmp.append(str(num))
                else:
                    if first_ichigo:
                        tmp.append(str(num))
                        first_ichigo = False
                    else:
                        num += 1
                        tmp.append(str(num))
            for _ in range(count):
                ans.append(tmp)
            count = 0
            ans.append(tmp)
        else:
            if is_find_first_ichigo:
                ans.append(tmp)
            else:
                count += 1

    for line in ans:
        print(" ".join(line))


if __name__ == "__main__":
    main()
//  [python]
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    h, w, k = rli()
    grid = []
    ans = [[-1 for _ in range(w)] for _ in range(h)]
    empty = [True for _ in range(h)]
    for i in range(h):
        ls = input()
        grid.append(ls)
        empty[i] = not('#' in ls)
    b = 1
    ft = {}
    le = []
    ne = -1
    for i in range(h):
        first = True
        if empty[i]:
            le.append(i)
            continue
        if len(le) > 0:
            ft[i] = le
            le = []
        ne = i
        for j in range(w):
            c = grid[i][j]
            if c == '#':
                if not first:
                    b += 1
                first = False
            ans[i][j] = b
        b += 1
    if len(le) > 0:
        ft.setdefault(ne, [])
        ft[ne].extend(le)
    for f, le in ft.items():
        for e in le:
            ans[e] = ans[f]
    # print(empty)
    # print(ft)
    for l in ans:
        print(" ".join(map(str, l)))



if __name__ == '__main__':
    main()