import numpy as np import itertools H, W, K = map(int, input().split()) pow_table = (K ** np.arange(H * W)).reshape((H, W)) pow_hash = lambda x: np.sum(x * pow_table) st = set() for t in itertools.product(range(K), repeat=H * W): if len(set(t)) != K: continue grid = np.array(t).reshape((H, W)) for h, w in itertools.product(range(H), range(W)): if pow_hash(np.roll(grid, (h, w), axis=(0, 1))) in st: break else: st.add(pow_hash(grid)) print(len(st))