jiahuimbzuai/CoQuIR huggingface dataset:
//  [ruby]
R = 'R'
L = 'L'

arr = gets.chomp

cross_indexes = []
humans = Array.new(arr.length, 0)
(arr.length-1).times do |i|
  if arr[i] == R && arr[i+1] == L
    cross_indexes.push(i)
  end
end
cross_indexes_for_left = cross_indexes.reverse

(arr.length).times do |i|
  if arr[i] == R
    target_index = cross_indexes.bsearch { |j| j >= i }
    if (target_index - i) % 2 == 0
      humans[target_index] += 1
    else
      humans[target_index + 1] += 1
    end
  else
    target_index = cross_indexes_for_left.bsearch { |j| j <= i }
    if (i - target_index) % 2 == 0
      humans[target_index] += 1
    else
      humans[target_index + 1] += 1
    end
  end
end

str = humans[0].to_s
(1..(humans.count - 1)).each do |i|
  str += ' ' + humans[i].to_s
end
puts str
//  [ruby]
S = gets.chomp
n = S.size
res = Array.new(n, 0)

def func(n, str, res, cnt = 0)
  n.times do |i|
    next cnt += 1 if str[i] == 'R'

    res[i] += cnt / 2
    res[i - 1] += (cnt + 1) / 2
    cnt = 0
  end

  res
end

res = func(n, S, res)

n.times { |i| S[i] = (S[i] == 'R') ? 'L' : 'R' }
res = func(n, S.reverse, res.reverse).reverse

puts res.join(' ')
//  [ruby]
S = gets.chomp.chars

# p S

S.each_with_index do |v, i|
  if v == 'R' && S[i + 1] == 'L'
    S[i] = 1
    S[i + 1] = 1
  end
end

# R の処理
S.each_with_index do |v, i|
  next unless v.to_s.match(/^R/)

  if S[i + 1] == 1
    l = S[i].length
    if l.even?
      S[i + 1] += l/2
      S[i + 2] += l/2
    else
      S[i + 1] += l/2
      S[i + 2] += (l/2 + 1)
    end
  elsif S[i + 1] == 'R'
    S[i + 1] += S[i]
  end
  S[i] = 0
end

# p S
# p S.reverse
RS = S.reverse
# L 側の処理
RS.each_with_index do |v, i|
  next unless v.to_s.match(/^L/)
  
  if RS[i + 1] != 'L'
    l = RS[i].length
    if l.even?
      RS[i + 1] += l/2
      RS[i + 2] += l/2
    else
      RS[i + 1] += l/2
      RS[i + 2] += (l/2 + 1)
    end
  elsif RS[i + 1] == 'L'
    RS[i + 1] += RS[i]
  end
  RS[i] = 0
end

# p RS
puts RS.reverse.join(' ')
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
use std::convert::TryInto;
use std::io::*;
use std::str::FromStr;
use superslice::*;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//abc128-C

#[fastout]
fn main() {
    // input!
    //     input! {
    //         n: u8,
    //         m: u8,
    //         sk: [[u8]; n],
    //         ps: [u8; m]
    //     }

    //     println!(
    //         r#"
    // n: {},
    // m: {},
    // sk: {:?},
    // ps: {:?}
    //         "#,
    //         n, m, sk, ps
    //     );

    // read
    // let n: usize = read();
    // let m: usize = read();
    // let mut s: Vec<Vec<usize>> = vec![vec![]; m];
    // let mut p: Vec<usize> = vec![];

    // for i in 0..m {
    //     let k = read();
    //     for _ in 0..k {
    //         s[i].push(read());
    //     }
    // }

    // for _ in 0..m {
    //     p.push(read());
    // }
    // let mut ans = 0;

    input![s: String,];

    let mut ans = vec![0; s.len()];

    //rlを探す
    let mut rl_idx = Vec::new();
    let mut previous_s = 'A';
    for (idx, s) in s.chars().enumerate() {
        if previous_s == 'R' && s == 'L' {
            rl_idx.push(idx - 1);
        }

        previous_s = s;
    }

    eprintln!("{:?}", rl_idx);

    //rlまでの距離をはかって、どちらかに足す
    for (idx, r_or_l) in s.chars().enumerate() {
        if idx == 0 {
            if &s[0..2] == "RL" {
                ans[0] += 1;
            } else {
                //Rまでの距離を図る
                let r_idx = rl_idx[rl_idx.upper_bound(&(idx))];
                eprintln!("R:{}, {}", idx, r_idx);
                let len = r_idx - idx;

                if len % 2 == 0 {
                    ans[r_idx] += 1;
                } else {
                    ans[r_idx + 1] += 1;
                }
            }
            continue;
        }
        if r_or_l == 'R' {
            //Rまでの距離を図る
            let r_idx = rl_idx[rl_idx.upper_bound(&(idx - 1))];
            eprintln!("R:{}, {}", idx, r_idx);
            let len = r_idx - idx;

            if len % 2 == 0 {
                ans[r_idx] += 1;
            } else {
                ans[r_idx + 1] += 1;
            }
        } else {
            //Lまでの距離を図る
            let l_idx = rl_idx[rl_idx.lower_bound(&idx) - 1];
            eprintln!("L:{}, {}", idx, l_idx);
            let len = (idx + 1) - l_idx;

            if len % 2 == 0 {
                ans[l_idx + 1] += 1;
            } else {
                ans[l_idx] += 1;
            }
        }
    }

    print!("{} ", ans[0]);

    for ans in &ans[1..] {
        print!("{} ", ans);
    }
}
//  [rust]
use proconio::{input, fastout};
use proconio::marker::{Chars};

macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
  }
}

#[fastout]
fn main() {
    input!{
        mut s: Chars,
    }
    let n = s.len();
    s.push('R');
    let mut r: bool = true;
    let mut l: bool = false;
    let mut spot_r = 0;
    let mut spot_l = n-1;
    let mut cnt = 0;
    // let mut sum = 0;
    let mut ans: Vec<usize> = vec![0;n];
    for i in 0..n+1 {
        if r==true && s[i]=='L' {
            r = false;
            l = true;
            spot_r = i-1;
            spot_l = i;
        }
        if l==true && s[i]=='R' {
            let tmp = cnt;
            cnt = i - cnt;
            r = true;
            l = false;
            if cnt%2==0 {
                ans[spot_r] = cnt/2;
                ans[spot_l] = cnt/2;
            } else {
                if (spot_r-tmp)%2==0 {
                    ans[spot_r] = cnt/2 + 1;
                    ans[spot_l] = cnt/2;
                } else {
                    ans[spot_r] = cnt/2;
                    ans[spot_l] = cnt/2 + 1;
                }
            }
            debug!(spot_r);
            debug!(cnt);
            cnt = i;
        }
    }

    for i in 0..n {
        print!("{} ",ans[i]);
    }
    // let mut dp: Vec<usize> = vec![0;n];
    // let mut o = 0;
    // let mut e = 0;
    // let mut spot = 0;
    // for i in 0..n-1 {
    //     if s[i]=='R' {
    //         if i%2!=0 {
    //             o += 1;
    //         } 
    //         if i%
    //         if s[i+1]=='L' {
    //             spot = i;
    //         }
    //     } else {
    //         if s[i+1]=='R' {
    //             dp[spot] = tmp;
    //             tmp = 0;
    //         } else {
    //             tmp += 1;
    //         }
    //     }
    // }

}
//  [rust]
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

// https://github.com/akiradeveloper/rust-comp-snippets/ \
// blob/fabb6a9811a955db3546f682679010e61022c472/src/union_find.rs
pub struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind {
            par: (0..n).collect::<Vec<usize>>(),
            rank: vec![1; n],
        }
    }

    pub fn size(&mut self, x: usize) -> usize {
        let y = self.root(x);
        self.rank[y]
    }

    pub fn same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }

    pub fn root(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            return x;
        } else {
            let y = self.par[x];
            let z = self.root(y);
            self.par[x] = z;
            return z;
        }
    }

    pub fn merge(&mut self, x: usize, y: usize) -> bool {
        let mut a = self.root(x);
        let mut b = self.root(y);
        if a == b {
            return false;
        }

        if self.rank[a] < self.rank[b] {
            std::mem::swap(&mut a, &mut b);
        }
        assert!(self.rank[a] >= self.rank[b]);

        self.rank[a] += self.rank[b];
        self.par[b] = a;
        return true;
    }
}

fn main() {
    input! {
        S: String,
    }

    // 偶数回動かすことになるので、2回後の変化に着目する

    // まず、それがゴールとなるマスかどうかを判定する O(N)

    // グループの情報をUnion Find木で表現する
    // 2回後に行くノードと同じグループにまとめる (O(N * a(n)))

    // それぞれのマスに対して、
    // ゴールとなるマスでないなら → 0
    // ゴールとなるマスならば → nodes()
    // UnionFind木をまとめる時に、そのノード数の情報も持っておくと良さそう

    let N = S.len();
    let mut isGoal = Vec::new();
    isGoal.resize(N, false);

    for i in 0..N {
        if i != N - 1 && &S[i..i + 1] == "R" && &S[i + 1..i + 2] == "L" {
            isGoal[i] = true;
        } else if i != 0 && &S[i..i + 1] == "L" && &S[i - 1..i] == "R" {
            isGoal[i] = true;
        }
    }


    let mut union_find = UnionFind::new(N);

    // まとめていく
    for i in 0..N {
        if isGoal[i] {
            continue;
        }

        // 問題文の制約から、境界をはみ出すことは無い
        let mut next = i;
        if &S[i..i + 1] == "R" {
            next = i + 1;
        }
        if &S[i..i + 1] == "L" {
            next = i - 1;
        }

        // 同じ処理をしているので、関数化も視野
        let mut next_next = next;
        if &S[next..next + 1] == "R" {
            next_next = next + 1;
        }
        if &S[next..next + 1] == "L" {
            next_next = next - 1;
        }

        // i と next_nextをマージ
        union_find.merge(i, next_next);
    }

    for i in 0..N {
        let size = if isGoal[i] { union_find.size(i) } else { 0 };
        println!("{}", size);
    }

}
//  [swift]
let S = readLine()!.characters.enumerate()
var ans = S.map{_ in 0}
var cnt = [0,0]
for (i,c) in S {
    if c == "R" {
        cnt[i%2]++
    } else {
        ans[i] += cnt[i%2]
        ans[i-1] += cnt[i%2^1]
        cnt = [0,0]
    }
}
for (i,c) in S.reverse() {
    if c == "L" {
        cnt[i%2]++
    } else {
        ans[i] += cnt[i%2]
        ans[i+1] += cnt[i%2^1]
        cnt = [0,0]
    }
}
ans.forEach{print($0,terminator:" ")}
//  [swift]
let S = readLine()!.characters
var ans = (0..<S.count).map{_ in 0}
var a = [0, 0]
for (i, c) in S.enumerate() {
    if c == "R" {
        a[i%2]++
    } else {
        ans[i] += a[i%2]
        ans[i-1] += a[i%2^1]
        a = [0, 0]
    }
}
for (i, c) in S.enumerate().reverse() {
    if c == "L" {
        a[i%2]++
    } else {
        ans[i] += a[i%2]
        ans[i+1] += a[i%2^1]
        a = [0, 0]
    }
}
ans.forEach{print($0, terminator: " ")}
//  [swift]
let S = readLine()!.characters
var ans = (0..<S.count).map{_ in 0}
var a = [0, 0]
for (i, c) in S.enumerate() {
    if c == "R" {
        a[i%2]++
    } else {
        ans[i] += a[i%2]
        ans[i-1] += a[(i%2)^1]
        a = [0, 0]
    }
}
for (i, c) in S.enumerate().reverse() {
    if c == "L" {
        a[i%2]++
    } else {
        ans[i] += a[i%2]
        ans[i+1] += a[(i%2)^1]
        a = [0, 0]
    }
}
print(ans.map{String($0)}.joinWithSeparator(" "))
//  [typescript]
function main(input) {
  const s = input.trim();
  let chunk = "";
  const result = [];
  for (let i = 0; i < s.length; i++) {
    const char = s[i];
    if (i === s.length - 1 || (chunk[chunk.length-1] === "L" && char === "R")) {
      if (i === s.length - 1) chunk += char;
      const arr = Array(chunk.length).fill(0);
      const rCnt = chunk.replace(/L/g, "").length;
      const lCnt = chunk.length - rCnt;
      if (chunk.length%2 === 0) {
        arr[rCnt-1] = chunk.length/2;
        arr[rCnt] = chunk.length/2;
        result.push(...arr); 
      } else {
        arr[rCnt-1] = rCnt%2 === 0 ? Math.floor(chunk.length/2) : Math.ceil(chunk.length/2);
        arr[rCnt] = chunk.length - arr[rCnt-1];
        result.push(...arr);
      }
      chunk = "";
    }
    chunk += char;
  }
  console.log(result.join(" ");
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
import math,heapq,collections,sys,numpy
sys.setrecursionlimit(10**7)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

H,W = LI()
LS = []
LS.append("@"*(W+2))
for _ in range(H):
    LS.append("@" + S() + "@")
LS.append("@"*(W+2))

def count(i,j):
    c = 0
    for k in range(-1,2):
        for l in range(-1,2):
            if LS[i+k][j+l] == "#":
                c +=1
    return c

for i in range(1,H+1):
    for j in range(1,W+1):
        if LS[i][j] == ".":
            LS[i] = LS[i][0:j] + str(count(i,j)) +  LS[i][j+1:W+2]

for i in range(1,H+1):
    print(LS[i][1:W+1])
//  [python]
h,w=map(int,input().split())
s=[input() for _ in [0]*h]
l=[]
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':l.extend([[i,j]])
a=''
for i in range(h):
    for j in range(w):
        if [i,j] in l:a+='#'
        else:
            c=0
            for m in l:
                if abs(i+j-sum(m))+abs(i-j-m[0]+m[1])==2:c+=1
            a+=str(c)
for i in range(h):print(a[w*i:w*(i+1)])
//  [python]
import numpy as np

def check_surrounding(array, h, w):
    count = 0
    if array[h, w] == "#":
        count+=1
    if array[h, w+1] == "#":
        count+=1
    if array[h, w+2] == "#":
        count+=1
    if array[h+1, w] == "#":
        count+=1
    if array[h+1, w+2] == "#":
        count+=1
    if array[h+2, w] == "#":
        count+=1
    if array[h+2, w+1] == "#":
        count+=1
    if array[h+2, w+2] == "#":
        count+=1
        
    return count


H, W = map(int, input().split())
grid = np.array([["0"]*(W+2)]*(H+2))
for h in range(H+2):
    if (h == 0) or (h==(H+1)):
        for w in range(W+2):
            grid[h, w] = "-"
        continue
    inputs =  input()
    for w in range(W+2):
        if (w == 0) or (w==(W+1)):
            grid[h, w] = "-"
        else:
            grid[h, w] = inputs[w-1]
            
# print(grid)

for h in range(H):
    for w in range(W):
        if grid[h+1, w+1] == "#":
            print("#", end="")
        else:
            print(check_surrounding(grid, h, w), end="")
    print()
//  [java]
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        String[] nums=new String[h];
        for(int i=0;i<h;i++){
            nums[i]=sc.next();
        }
        int[][] output=new int[h][w];
        int[] x={1,1,0,-1,-1,-1,0,1};
        int[] y={0,1,1,1,0,-1,-1,-1};
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(nums[i].charAt(j)=='#'){
                    output[i][j]=-1;
                    continue;
                }
                for(int k=0;k<8;k++){
                    try{
                        if(nums[i+x[k]].charAt(j+y[k])=='#')output[i][j]++;
                    }catch(Exception e){}
                }
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                System.out.print(output[i][j]>=0?output[i][j]:"#");
            }
            System.out.println();
        }
    }
}
//  [java]
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        boolean[][] bom = new boolean[H + 2][W + 2];
        for (int i = 0; i < H + 2; i++) {
            for (int j = 0; j < W + 2; j++) {
                bom[i][j] = false;
            }
        }
        for (int i = 0; i < H; i++) {
            String line = sc.next();
            for (int j = 0; j < W; j++) {
                if (line.charAt(j) == '#') {
                    bom[i + 1][j + 1] = true;
                } else {
                    bom[i + 1][j + 1] = false;
                }
            }
        }
        for (int i = 1; i < H + 1; i++) {
            for (int j = 1; j < W + 1; j++) {
                if (bom[i][j]) {
                    System.out.print('#');
                } else {
                    int nBoms = 0;
                    if (bom[i - 1][j - 1]) {
                        nBoms++;
                    }
                    if (bom[i - 1][j]) {
                        nBoms++;
                    }
                    if (bom[i - 1][j + 1]) {
                        nBoms++;
                    }
                    if (bom[i][j - 1]) {
                        nBoms++;
                    }
                    if (bom[i][j + 1]) {
                        nBoms++;
                    }
                    if (bom[i + 1][j - 1]) {
                        nBoms++;
                    }
                    if (bom[i + 1][j]) {
                        nBoms++;
                    }
                    if (bom[i + 1][j + 1]) {
                        nBoms++;
                    }
                    System.out.print(nBoms);
                }
            }
            System.out.println();
        }
    }
}
//  [java]
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());
        String[] s = new String[H];
        String[][] S = new String[H][W];
        int[] dx = { 1, 0, -1, 0, 1, -1, -1, 1 };
        int[] dy = { 0, 1, 0, -1, 1, 1, -1, -1 };
        Integer count;
        String line = "";

        for (int i = 0; i < H; i++) {
            s[i] = sc.next();
            for (int j = 0; j < W; j++) {
                S[i][j] = s[i].split("")[j];
            }
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                count = 0;
                for (int d = 0; d < 8; d++) {
                    int nx = j + dx[d];
                    int ny = i + dy[d];

                    if (nx >= 0 && nx < W && ny >= 0 && ny < H) {
                        if (S[ny][nx].equals("#") && !S[i][j].equals("#")) {
                            count++;
                        }
                    }

                    if (!S[i][j].equals("#")) {
                        S[i][j] = count.toString();
                    }

                }
            }
        }

        PrintWriter out = new PrintWriter(System.out);

        for (int i = 0; i < H; i++) {

            line = "";
            for (int j = 0; j < W; j++) {
                line += S[i][j];
            }

            out.println(line);
        }

        sc.close();
        out.flush();
    }
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;

char a[100][100];

int main() {
    ios_base::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (a[i][j] != '#') {
                a[i][j] = '0';
                if (a[i-1][j-1] == '#') {
                    a[i][j]++;
                }
                if (a[i-1][j] == '#') {
                    a[i][j]++;
                }
                if (a[i-1][j+1] == '#') {
                    a[i][j]++;
                }
                if (a[i][j-1] == '#') {
                    a[i][j]++;
                }
                if (a[i][j+1] == '#') {
                    a[i][j]++;
                }
                if (a[i+1][j] == '#') {
                    a[i][j]++;
                }
                if (a[i+1][j-1] == '#') {
                    a[i][j]++;
                }
                if (a[i+1][j+1] == '#') {
                    a[i][j]++;
                }
            }
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << a[i][j];
        }
        cout << endl;
    }
    cout << endl;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define ll long long


using namespace std;

const int MAXN = (int) 50;

int dl[] = {-1, -1, -1, 0, 0, 1, 1, 1}, dc[] = {-1, 0, 1, -1, 1, -1, 0, 1};

string str[MAXN + 1];

int ans[MAXN + 1][MAXN + 1];

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, j, n, m;
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for(i = 1; i <= n; i++) {
        cin >> str[i];
        str[i] = " " + str[i];
    }
    for(i = 1; i <= n; i++) {
        for(j = 1; j <= m; j++) {
            for(int p = 0; p < 8; p++) {
            int l = i + dl[p];
            int c = j + dc[p];
            if(l > 0 && l <= n && c > 0 && c <= m && str[l][c] == '#')
               ans[i][j]++;
            }
        }
    }
    for(i = 1; i <= n; i++) {
        for(j = 1; j <= m; j++) {
            if(str[i][j] == '#')
                cout << str[i][j];
            else
                cout << ans[i][j];
        }
        cout << endl;
    }
    //cin.close();
    //cout.close();
    return 0;
}
//  [cpp]
#include <iostream>
#include <string>
using namespace std;
int h, w;
string s[64];
string t[64];

void func(int x, int y) {
  int n = 0;
  int d[] = {1, 0, -1};
  if (s[y][x] == '#')
    return;

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (d[i] == 0 && d[j] == 0)
        continue;
      int xx = x + d[j], yy = y + d[i];
      if (0 <= xx && xx < w && 0 <= yy && yy < h && s[yy][xx] == '#')
        n++;
    }
  }
  t[y][x] = '0' + n;
}

int main(void) {
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> s[i];
    t[i] = s[i];
  }
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      func(j, i);
  for (int i = 0; i < h; i++)
    cout << t[i] << endl;
}
//  [c]

#include <stdio.h>

int main(void) {
    int i,j;
    int h,w;
    
    scanf("%d",&h);
    scanf("%d",&w);
    
    char S[h+1][w+1];
    int B[h+1][w+1];
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            B[i][j] = 0;
        }
    }
    
    for(i=0;i<h;i++){
        scanf("%s",S[i]);
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(S[i][j] == '#'){
                if(i>=1 && j>=1) B[i-1][j-1]++;
                if(i>=1) B[i-1][j]++;
                if(i>=1 && j<=w-1) B[i-1][j+1]++;
                if(j>=1) B[i][j-1]++;
                if(j<=w-1) B[i][j+1]++;
                if(i<=h-1 && j>=1) B[i+1][j-1]++;
                if(i<=h-1) B[i+1][j]++;
                if(i<=h-1 && j<=w-1) B[i+1][j+1]++;
                //bombN
                
                
            }
        }
    }
    
    
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(S[i][j] == '#'){
                printf("#");
            }else{
                printf("%d",B[i][j]);
            }
        }
        printf("\n");
    }
    return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#pragma warning(disable : 4996)

int main()
{
    int H, W;
    int i, j, k, l;

    char s[100][60];
    char a[100][60] = {""};
    int count = 0;

    scanf("%d %d", &H, &W);

    for (i = 0; i < H; i++) {
        scanf("%s", s[i]);
    }

    for (i = 0; i <= H; i++) {
        for (j = 0; j < W; j++) {
            count = 0;
            if (s[i][j] == '#') {
                a[i][j] = '#';
                continue;
            }

            for (k = -1; k < 2; k++) {
                for (l = -1; l < 2; l++) {
                    if (k == 0 && l == 0)
                        continue;
                    if (i + k < 0 || j + l < 0)
                        continue;
                    if (s[i + k][j + l] == '#')
                        count++;
                }
            }

            a[i][j] = '0'+count;

        }
    }





    for (i = 0; i < H; i++) {
        printf("%s\n",a[i]);
    }

    return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
int main (void){
  char rowCol[100000][50];/*行列*/
  int numRow,numCol;
  int i,j,k,l;
  int rowColNum[100000][51]={0};
  
  if(scanf("%d %d\n",&numRow,&numCol));
  
  for(i=0;i<numRow;i++){
      if(scanf("%s\n",rowCol[i])); 
  }
  
  //for(i=0;i<numRow;i++){
      //printf("i=%d row[i]=%s\n",i,&rowCol[i]);/*(注意)star型の時は、&をつけ出力*/
  //}
  
  for(i=0;i<numRow;i++){
    for(j=0;j<numCol;j++){      
      //printf("%s",&rowCol[i][j]);      
      //rowCol[i][j] == "#"
      
      //if(strncmp(".",&rowCol[k][l],1)==0){
         //rowColNum[i][j] = 0;  
      //}
      if(strncmp("#",&rowCol[i][j],1)==0){
         rowColNum[i][j] = 9;
         for(k=i-1;k<=i+1;k++){
           for(l=j-1;l<=j+1;l++){ 
             if(k==i&&l==j || rowColNum[k][l]==9){
               continue;
             }
             rowColNum[k][l] += 1;
      	   }
         }
      }
         
    }    
  }
    //printf("i=%d %s\n",i,&rowCol[i]);
  
    
  //for(i=0;i<numRow;i++){
      //printf("i=%d row[i]=%s\n",i,rowCol[i]);/*(注意)star型の時は、&をつけ出力*/
  //}
  
  for(i=0;i<numRow;i++){
    for(j=0;j<numCol;j++){
      if(rowColNum[i][j]==9){
        printf("#");
        continue;
        //rowColNum[i][j] = "#";  
      }
      else{
        printf("%d",rowColNum[i][j]);
      }
      //rowCol[i][j] = (char)rowColNum[i][j];
    }
    printf("\n");
  }
  //printf("rowCol=%s",rowColNum[0]);
  
  //for(i=0;i<numRow;i++){
      //printf("i=%d row[i]=%s\n",i,rowCol[i]);/*(注意)star型の時は、&をつけ出力*/
  //}
    
  return 0;
}
//  [javascript]
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [h, w] = nextIntArray()
    let s = []
    while (hasNext()) {
        s.push(next())
    }
    let a = Array.from( new Array(h), _ => new Array(w).fill(0))
    let dir = [
        [-1, -1],
        [-1, 0],
        [-1, 1],
        [0, -1],
        [0, 1],
        [1, -1],
        [1, 0],
        [1, 1],
    ]
    for (let i = 0; i < s.length; i++) {
        for (let j = 0; j < s[i].length; j++) {
            if (s[i][j] == "#") {
                a[i][j] = "#"
            } else {
                let cnt = 0
                for (let d of dir) {
                    let x = j + d[0]
                    let y = i + d[1]
                    if (0 <= x && x < s[0].length && 0 <= y && y < s.length) {
                        if (s[y][x] == "#") cnt++
                    }
                }
                a[i][j] = cnt
            }
        }
    }
    for (let l of a) {
        console.log(l.join(""))
    }
}
Main()
//  [javascript]
function Main(input) {
    //xは縦芳香、ｙは横方向で8芳香の動き方
    var dx = [1,1,0,-1,-1,-1,0,1];
    var dy = [0,1,1,1,0,-1,-1,-1];
    
    var input = input.split('\n');
    var hw = input[0].split(' ').map(n => parseInt(n, 10));
    var h = hw[0];
    var w = hw[1];
    //二重配列にして升目作る,arr[i行][j列]で各マスをとってこれるようになる
    var board = [];
    for(i = 1; i <= h; i++) board.push(input[i].split(''));
    //爆弾を除いた全てのマスから8芳香探索して爆弾の数を数えてその数をマスに入れる
    for(i = 0; i < h; i++) {
        for(j = 0; j < w; j++) {　//まず全てのマスを参照するfor文を回す
            if(board[i][j] == '#') continue;　//爆弾を除く
            var cnt = 0;
            //八芳香を見ていく。マス(i,j)からk番目の方向に進む先は
            //(i+dx[k], j+dy[k])となる(0<= k < 8)
            for(k = 0; k < 8; k++) {
                x = i + dx[k];
                y = j + dy[k];
                //(x,y)が枠外に行かないかつ爆弾である時にカウントする
                if(x >= 0 && x < h && y >= 0 && y < w && board[x][y] == '#') cnt++;
            }
            //8芳香のカウントが終わった後マスにその数字をを入れる
            board[i][j] = cnt;
        }
    }
    //boardをは二重の配列になってるのでboardでコンソールすると配列で出力されるし、多段にならない。
    //board[i行]の要素をjoinしてboard[i行]をループ出力すると文字列かつ多段に出力される。
    for(i = 0; i < h; i++) console.log(board[i].join(''))
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
"use strict";

main(require("fs").readFileSync("/dev/stdin", "UTF-8")); // 3 5
// .....
// .#.#.
// .....

function main(input) {
  var height = 0;
  var width = 0;
  input.split("\n")[0].split(" ").map(function (value, index) {
    switch (index) {
      case 0:
        height = parseInt(value);
        break;

      case 1:
        width = parseInt(value);
        break;

      default:
        console.log("入力の１行目を判断出来ません。");
    }
  });
  var mass = new Array(height); // 各マスの状態
  // 2次元配列の生成

  for (var i = 0; i < mass.length; i++) {
    mass[i] = new Array(width);
  } // 2次元配列に値を格納


  for (var h = 0; h < height; h++) {
    mass[h] = input.split("\n")[h + 1].split("").slice();
  }

  var result = mass.slice();

  for (var _h = 0; _h < height; _h++) {
    for (var w = 0; w < mass[_h].length; w++) {
      if (mass[_h][w] !== "#") {
        (function () {
          var relationMass = [];
          var atomic_count = 0;

          if (_h - 1 >= 0) {
            if (w - 1 >= 0) {
              relationMass.push(mass[_h - 1][w - 1]);
            }

            if (w + 1 <= width) {
              relationMass.push(mass[_h - 1][w + 1]);
            }

            relationMass.push(mass[_h - 1][w]);
          }

          if (w - 1 >= 0) {
            relationMass.push(mass[_h][w - 1]);
          }

          if (w + 1 <= width) {
            relationMass.push(mass[_h][w + 1]);
          }

          if (_h + 1 < height) {
            if (w - 1 >= 0) {
              relationMass.push(mass[_h + 1][w - 1]);
            }

            if (w + 1 <= width) {
              relationMass.push(mass[_h + 1][w + 1]);
            }

            relationMass.push(mass[_h + 1][w]);
          }

          relationMass.forEach(function (e) {
            if (e === "#") {
              atomic_count++;
            }
          });
          result[_h][w] = atomic_count;
        })();
      }
    }
  }

  console.log(result = result.map(function (a) {
    return a.join("");
  }).join("\n"));
}
//  [go]
package main

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

// const abcd = "abcdefghijklnmopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// const dx = [...]int{0, 1, 0, -1}
// const dy = [...]int{1, 0, -1, 0}

///////////////////////////////////////////////////

func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	H := next.Int()
	W := next.Int()
	s := make([]string, H)
	for i := 0; i < H; i++ {
		s[i] = next.Line()
	}
	ans := make([][]byte, H)
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if s[i][j] == '.' {
				cnt := 0
				for k := 0; k < 8; k++ {
					ny := i + dy[k]
					nx := j + dx[k]
					if in(ny, 0, H) && in(nx, 0, W) {
						log.Println(ny, nx)
						cnt += btoi(s[ny][nx] == '#')
					} else {
						continue
					}
				}
				ans[i] = append(ans[i], byte(cnt)+'0')
			} else {
				ans[i] = append(ans[i], '#')
			}
		}
	}
	for i := 0; i < H; i++ {
		fmt.Println(string(ans[i]))
	}

}

///////////////////////////////////////////////////
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) nextInt64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}
//  [go]
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scanf("%d %d", &h, &w)

	ss := make([]string, h)

	type Bomb struct {
		X int
		Y int
	}
	bomb := []Bomb{}

	for i := 0; i < h; i++ {
		var s string
		fmt.Scanf("%s", &s)
		ss[i] = s
		for k, v := range s {
			if v == 35 {
				bomb = append(bomb, Bomb{X: i, Y: k})
			}
		}
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			s := ss[i][j]
			if s == 35 {
				fmt.Printf("%s", "#")
				continue
			}
			cnt := 0
			for m := -1; m < 2; m++ {
				for n := -1; n < 2; n++ {
					tx := i + m
					ty := j + n
					if tx < 0 || ty < 0 {
						continue
					}
					for _, b := range bomb {
						if b.X == tx && b.Y == ty {
							cnt = cnt + 1
						}
					}
				}
			}
			fmt.Printf("%d", cnt)
		}
		fmt.Printf("\n")
	}
}
//  [ruby]
require 'pp'

def fill(c)

	w = c[0].length
	h = c.length

	for y in Range.new(0, h, true) do
		for x in Range.new(0, w, true) do
			if c[y][x] == '.' then
				candidate = [[-1, -1], [0, -1], [1, -1],
							 [-1,  0],          [1,  0],
							 [-1,  1], [0,  1], [1,  1]]
				bombs = 0
				for a in candidate do
					ix = x + a[0]
					iy = y + a[1]
					if ix >= 0 and iy >= 0 and ix < w and iy < h then
						if c[iy][ix] == '#' then
							bombs += 1
						end
					end
				end
				c[y][x] = bombs
			end
		end
	end

end


h, _ = gets.chomp.split(/ /)
h = h.to_i
c = []
for i in Range.new(0, h, true) do
	c[i] = gets.chomp.split(//)
end

fill(c)
for i in Range.new(0, h, true) do
	puts c[i].join()
end
//  [ruby]
#set 
h,w = gets.chomp.split(" ").map(&:to_i)

line = Array.new(h)
squeares = Array.new(h) {Array.new(w, 0)}
answers = Array.new(h) {Array.new(w, 0)}

(0 .. h - 1).each do |i|
    line[i] = gets.chomp
    (0 .. w - 1).each do |j|
        squeares[i][j] = line[i].split("")[j]
    end
end

#main
(0 .. h - 1).each do |i|
    (0 .. w - 1).each do |j|
        if squeares[i][j] == '#' then
            answers[i][j] = squeares[i][j]
            (i - 1 .. i + 1).each do |k|
                (j - 1 .. j + 1).each do |l|
                    if k >= 0 && k < h && l >= 0 && l < w then
                        if k == i && l == j then
                            next
                        else
                            if answers[k][l] != '#' then
                                answers[k][l] = (answers[k][l].to_i + 1).to_s
                            end
                        end
                    end
                end
            end
        end
    end
end

(0 .. h - 1).each do |i|
    print ("#{answers[i].join}\n")
end
//  [ruby]
H,W=gets.split.map(&:to_i)
S=[]
H.times{
    S<<gets.chomp
}
H.times{|h|
    W.times{|w|
        next if S[h][w]=="#"
        c=0
        (h-1 .. h+1).each{|y|
            next if y<0
            next if y>=H
            (w-1 .. w+1).each{|x|
                next if x<0
                next if x>=W
                if S[y][x]=="#"
                    c+=1
                end
            }
        }
        S[h][w]=c.to_s
    }
}
puts S
//  [rust]
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        h: usize,
        w: usize,
    }

    let mut b: Vec<Vec<char>> = vec![vec!['0';w+2];1];
    for i in 0..h {
        let mut tmp: Vec<char> = vec!['0';1];
        input!{
            c: Chars,
        }
        tmp.extend(c);
        tmp.push('0');
        b.push(tmp);
    }
    b.push(vec!['0';w+2]);
    debug!(b);
    let mut cnt = 0;
    for i in 1..h+1 {
        for j in 1..w+1 {
            if b[i][j]=='.' {
                if b[i-1][j-1]=='#' {
                    cnt += 1;
                }
                if b[i-1][j]=='#' {
                    cnt += 1;
                }
                if b[i-1][j+1]=='#' {
                    cnt += 1;
                }
                if b[i][j-1]=='#' {
                    cnt += 1;
                }
                if b[i][j+1]=='#' {
                    cnt += 1;
                }
                if b[i+1][j-1]=='#' {
                    cnt += 1;
                }
                if b[i+1][j]=='#' {
                    cnt += 1;
                }
                if b[i+1][j+1]=='#' {
                    cnt += 1;
                }
                debug!(cnt);
                print!("{}",cnt);
            } else {
                print!("#");
            }
            cnt = 0;
        }
        print!("\n");
    }
    print!("\n");

}
//  [rust]
fn read_multi<T: std::str::FromStr>() -> Vec<T> {
    let mut s = std::string::String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_column<T: std::str::FromStr>(n: i32) -> Vec<T> {
    let mut v = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        v.push(s.trim().parse().ok().unwrap());
    }
    v
}

fn add_frame(vvc: Vec<Vec<char>>, cr: char) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = std::vec::Vec::<std::vec::Vec::<char>>::new();

    let cnum: usize = vvc[0].len();
    let mut vul: Vec<char> = std::vec::Vec::<char>::new();
    for _ in 0..cnum + 2 {
        vul.push(cr);
    }
    ret.push(vul);

    for i in 0..vvc.len() {
        let mut vi: Vec<char> = std::vec::Vec::<char>::new();
        vi.push(cr);
        for j in 0..cnum {
            vi.push(vvc[i][j]);
        }
        vi.push(cr);
        ret.push(vi);
    }

    let mut vll: Vec<char> = std::vec::Vec::<char>::new();
    for _ in 0..cnum + 2 {
        vll.push(cr);
    }
    ret.push(vll);

    ret
}


fn main() {
    let vn: Vec<i32> = read_multi(); //i32
    // println!("{:?}", vn);

    let vs: Vec<String> = read_column(vn[0]);
    let mut vvc: Vec<Vec<char>> = std::vec::Vec::<std::vec::Vec::<char>>::new();
    for i in 0..vs.len() {
        let vc: Vec<char> = vs[i].chars().collect();
        vvc.push(vc);
    }
    // println!("{:?}", vvc);

    let framed: Vec<Vec<char>> = add_frame(vvc, '.');
    // println!("{:?}", framed);


    for i in 1..(vn[0] + 1) as usize {
        let mut res: String = std::string::String::new();
        for j in 1..(vn[1] + 1) as usize {
            if framed[i][j] == '#' {
                res.push('#');
            } else {
                let mut n: i32 = 0;
                if framed[i - 1][j - 1] == '#' {    n += 1;    }
                if framed[i - 1][j    ] == '#' {    n += 1;    }
                if framed[i - 1][j + 1] == '#' {    n += 1;    }
                if framed[i    ][j - 1] == '#' {    n += 1;    }
                if framed[i    ][j + 1] == '#' {    n += 1;    }
                if framed[i + 1][j - 1] == '#' {    n += 1;    }
                if framed[i + 1][j    ] == '#' {    n += 1;    }
                if framed[i + 1][j + 1] == '#' {    n += 1;    }
                res.push(std::char::from_digit(n as u32, 10).unwrap());
            }
        }
        println!("{}", res);
    }
}
//  [rust]
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        h: usize, w: usize,
        s: [Chars; h],
    }

    let mut ans = vec![vec!['#'; w]; h];

    let directions = [(0, 1), (1, 0), (-1, 0), (0, -1), (1, 1), (1, -1), (-1, 1), (-1, -1)];

    for x in 0..w {
        for y in 0..h {
            if s[y][x] == '#' { continue; }
            let mut cnt = 0;
            for &(dx, dy) in directions.iter() {
                let (cx, cy) = (x as isize + dx, y as isize + dy);
                if cx < 0 || cy < 0 || cx >= w as isize || cy >= h as isize {continue;}
                if s[cy as usize][cx as usize] == '#' {
                    cnt += 1;
                }
            }
            ans[y][x] = std::char::from_digit(cnt, 10).unwrap();
        }
    }

    println!("{}", ans.iter().map(|x| x.iter().join("")).join("\n"));
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}
//  [typescript]
import { readFileSync } from "fs";

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

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

  const empty = ".";
  const bomb = "#";

  const field = input.slice(1, -1).map((line) => line[0].split(""));

  for (let i = 0; i < H; i++) {
    for (let j = 0; j < W; j++) {
      if (field[i][j] !== empty) {
        continue;
      }

      let bombs = 0;

      for (let ii = i - 1; ii <= i + 1; ii++) {
        for (let jj = j - 1; jj <= j + 1; jj++) {
          if (ii === i && jj === j) {
            continue;
          }
          if (ii < 0 || ii >= H || jj < 0 || jj >= W) {
            continue;
          }

          if (field[ii][jj] === bomb) {
            bombs += 1;
          }
        }
      }

      field[i][j] = bombs.toString();
    }
  }

  return field.map((row) => row.join("")).join("\n");
};

console.log(main(read()));
//  [python]
n=int(input())
print(n**3)
//  [python]
print(int(input())**3)
//  [python]
n = int(input())
print (n*n*n)
//  [python]
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
print(N**3)
//  [python]
import numpy as np

N = int(input())
print(N * N * N)
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
  public static void main(String[] args) throws Exception {
    int n;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      n = Integer.parseInt(br.readLine());
    }
    System.out.println(n*n*n);
  }
}
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int n = Integer.parseInt(W);


		System.out.println(n*n*n);
	}
}
//  [java]

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        FastReader fr = new FastReader();
        int n = fr.nextInt();
        System.out.println((int)Math.pow(n, 3));
    }

}

class FastReader {
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public FastReader() {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public FastReader(String file_name) throws IOException {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1) {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');

        if (c == '.') {
            while ((c = read()) >= '0' && c <= '9') {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException {
        if (din == null)
            return;
        din.close();
    }
}
//  [java]
import java.util.*;
import java.lang.*;

class Mod{
    static final long MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long adds(long... ar){
        long ans=0;
        for(long x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long mults(long... ar){
        long ans=1;
        for(long x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }

}

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(Mod.power(N,3));
    }
}