jiahuimbzuai/CoQuIR huggingface dataset:
//  [swift]
/// 10
var (_,k) = cin.pair
/// [2, 3, 4, 5, 6, 4]
/// [1, 2, 3, 4, 5, 3]
let A = cin.array.map { $0-1 }
/// []
var seen = [Int]()
/// 0
var current = 0

while true {
    seen.append(current)
    current = A[current]
    k -= 1

    if k == 0 {
        break
    }

    if seen.contains(current) {
        break
    }
}

/// seen: [0, 1, 2, 3, 4, 5]
/// current: 5
/// loop: [4, 5, 3]
/// k: 10 - 5 = 5

let loop = Array(seen[seen.firstIndex(of: current)!..<seen.count])

/// res = 5%3 = 2
/// loop[2] = 3
/// ans: 5 (index: 4)

let ans = loop[k%loop.count]
print(ans+1)


// MARK: #### 以下、ライブラリ ####

import Foundation
#if os(Linux)
    import Glibc
#else
    import Darwin.C
#endif

enum cin {
    // 123
    static var int: Int { Int(readLine()!)! }
    // 12 23
    static var pair: (Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!) }
    // 12 23 34
    static var triple: (Int, Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!, Int(line[2])!) }
    // AtCoder
    static var str: String { readLine()! }
    // At Coder
    static var arrayStr: [String] { str.components(separatedBy: " ") }
    // 1 2 3 4
    static var array: [Int] { str.components(separatedBy: " ").map { Int($0)! } }
    // 1
    // 2
    // 3
    static func v_array(count: Int) -> [Int] { (0..<count).map { _ in int } }
}

extension Int {
    // 123 -> [1, 2, 3]
    var digits: [Int] { Array(String(self)).map { Int(String($0))! } }
}

extension Array where Element == Int {
    // [2, 1, 3, 2] -> 8
    var sum: Int { self.reduce(0, +) }
    // [2, 1, 3, 2] -> [1, 2, 2, 3]
    var orderBy: [Int] { sorted() }
    // [2, 1, 3, 2] -> [3, 2, 2, 1]
    var orderByDesc: [Int] { sorted(by: { $0 > $1 }) }
    // [2, 1, 3, 2] -> [2, 1, 3]
    var distinct: [Int] { Array(Set(self)) }
}

precedencegroup PowerPrecedence { higherThan: MultiplicationPrecedence }
infix operator ^^ : PowerPrecedence
func ^^ (radix: Int, power: Int) -> Int {
    return Int(pow(Double(radix), Double(power)))
}

extension String {
    // e.g. cin.line.regex(match: "^(dream|dreamer|erase|eraser)*$")
    func regex(match pattern: String) -> Bool {
        let regex = try! NSRegularExpression(pattern: pattern)
        return regex.firstMatch(in: self, range: NSRange(location: 0, length: self.count)) != nil
    }
    // "ABC"[1] -> "B"
    subscript(i: Int) -> Character {
        get {
            self[index(at: i)]
        }
        set(char) {
            var characters = Array(self)
            characters[i] = char
            self = String(characters)
        }
    }
    func index(at offset: Int) -> String.Index { index(startIndex, offsetBy: offset) }
    // "ABC".swapAt(0, 1) -> "BAC"
    mutating func swapAt(_ index1: Int, _ index2: Int) {
        var characters = Array(self)
        characters.swapAt(index1, index2)
        self = String(characters)
    }
}
//  [typescript]
import * as fs from 'fs'

const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n')
const n = +input[0].split(' ')[0]
const k = BigInt(input[0].split(' ')[1])
const a = input[1].split(' ').map(x => +x)
let cur = 0
if (k <= n) {
  for (let i = 0; i < k; i++) {
    cur = a[cur] - 1
  }
} else {
  let visited = new Array(n).fill(-1)
  visited[0] = 0
  let teleport = 0
  let loop = 0
  for (let i = 0; i < n; i++) {
    cur = a[cur] - 1
    teleport = i + 1
    if visited[cur] >= 0 {
      loop = teleport - visited[cur]
      break
    } else {
      visited[cur] = teleport
    }
  }
  for (let i = 0; i < (k - BigInt(teleport)) % BigInt(loop); i++) {
    cur = a[cur] - 1
  }
}
console.log(cur + 1)
//  [typescript]
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const n = +input[0].split(" ")[0];
let _k = BigInt(input[0].split(" ")[1]);
const a = input[1].split(" ").map((x: string): number => (+x) - 1);

let current = 0;
const visited = new Map();
let count = 0;
while (!visited.has(current)) {
	visited.set(current, count);
	current = a[current];
	count++;
}
const d = BigInt(visited.get(current)!);
const loop_length = BigInt(count) - d;
const k = _k < d + loop_length ? Number(_k) : Number(d + ((_k - d) % loop_length));
current = 0;
for (let i = 0; i < k; i++) {
	current = a[current];
}
console.log(current + 1);
//  [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, k] = inputs[0].split(' ').map(BigInt);
  const city = inputs[1].split(' ').map(BigInt);
  let roopSet = new Set<number>();
  let roop: number[] = [];
  let roopStart = 0;
  let teleport = 1;
  let isRoopExist = false;

  for (let i = 1; i <= k; i++) {
    if (!roopSet.has(teleport)) {
      roopSet.add(teleport);
    } else if (i < k && roopSet.has(teleport)) {
      roopSet.forEach((value) => roop.push(value));
      roop = roop.slice(roop.indexOf(teleport), roop.length);
      isRoopExist = true;
      break;
    }
    teleport = Number(city[teleport - 1]);
    roopStart++;
  }

  if (isRoopExist) {
    teleport = roop[Number((k - BigInt(roopStart)) % BigInt(roop.length))];
  }

  console.log(teleport);
}
//  [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, k] = inputs[0].split(' ').map(BigInt);
  const city = inputs[1].split(' ').map(BigInt);
  let roop: number[] = [];
  let roopStart = 0;
  let teleport = 1;
  let isRoopExist = false;

  for (let i = 1; i <= k; i++) {
    if (roop.indexOf(teleport) === -1) {
      roop.push(teleport);
    } else if (i < k && roop.indexOf(teleport) !== -1) {
      roopStart = roop.indexOf(teleport);
      roop = roop.slice(roopStart, roop.length);
      isRoopExist = true;
      break;
    }
    teleport = Number(city[teleport - 1]);
  }

  if (isRoopExist) {
    teleport = roop[Number((k - BigInt(roopStart)) % BigInt(roop.length))];
  }

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

const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n')
const n = +input[0].split(' ')[0]
const k = BigInt(input[0].split(' ')[1])
const a = input[1].split(' ').map(x => +x)
let visited = new Array(n).fill(-1)
visited[0] = 0
let cur = 0
let teleport = 0
let loop = 0
for (let i = 0; i < n; i++) {
  cur = a[cur] - 1
  teleport = i + 1
  if visited[cur] >= 0 {
    loop = teleport - visited[cur]
    break
  } else {
    visited[cur] = teleport
  }
}
for (let i = 0; i < (k - BigInt(teleport)) % BigInt(loop); i++) {
  cur = a[cur] - 1
}
console.log(cur + 1)
//  [typescript]
import * as fs from 'fs'

const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n')
const [n, k] = input[0].split(' ').map(x => +x)
const a = input[1].split(' ').map(x => +x)
let visited = new Array(n).fill(-1)
visited[0] = 0
let cur = 0
let teleport = 0
let loop = 0
for (let i = 0; i < n; i++) {
  cur = a[cur] - 1
  teleport = i + 1
  if visited[cur] >= 0 {
    loop = teleport - visited[cur]
    break
  } else {
    visited[cur] = teleport
  }
}
for (let i = 0; i < (k - teleport) % loop; i++) {
  cur = a[cur] - 1
}
console.log(cur + 1)
//  [python]
def factorial(n):
    ans = 1
    for i in range(2, n + 1):
        ans = ans * i % 1000000007
    return ans
n, m = map(int, input().split())
MOD = 10**9 + 7
if n == m:
    print(2 * factorial(n) ** 2 % MOD)
elif abs(n - m) == 1:
    print(factorial(min(m, n)) ** 2 * max(m, n) % MOD)
else:
    print(0)
//  [python]
import math

def factorial(n):
    val = 1
    for i in range(2, n + 1):
        val =  val * i % 1000000007
    return val

n,m= (int(i) for i in input().split())

if n==m:
    a = factorial(n)
    print(2 * a * a % 1000000007)
elif abs(n-m) == 1:
    a = factorial(min(m,n))
    print(a * a * max(m,n) % 1000000007)
else:
    print(0)
//  [python]
# ABC065C - Reconciled? (ARC076C)
def factorial_mod(x: int) -> int:
    MOD = 10 ** 9 + 7  # change the value if needed
    ret = 1
    for i in range(1, x + 1):
        ret = (ret * i) % MOD
    return ret


def main():
    n, m = list(map(int, input().rstrip().split()))
    MOD = 10 ** 9 + 7
    n, m = min(n, m), max(n, m)
    dif = m - n
    if dif > 1:  # must be ...DDM...
        print(0)
    else:
        if dif == 0:  # start with either D or M (DM..., MD...)
            ans = (factorial_mod(n) ** 2 * 2) % MOD  # n == m -> (n!)^2 * 2
        else:  # sandwich (DMD or MDM)
            ans = (factorial_mod(n) ** 2 * m) % MOD  # n + 1 == m -> (n!)^2 * m
        print(ans)


if __name__ == "__main__":
    main()
//  [python]
n,m = map(int, input().split())
if n > m:
    n,m = m,n
ans = 1
if m==n:

    while n > 0:
        ans *= n
        ans %= 10**9+7
        n -= 1
    ans = (2*(ans**2))%(10**9+7)
    print(ans)

elif m - n == 1:
    while n > 0:
        ans *= n
        ans %= 10**9+7
        n -= 1
    
    ans = (ans * (ans*m % 10**9+7)) % (10**9+7)
    print(ans)
else:
    print(0)
//  [python]
N, M = map(int, input().split())
from math import factorial
mod = 10**9+7

if abs(N-M) > 1:
    print(0)
else:
    print(2*factorial(N)*factorial(M)%mod)
//  [python]
n, m = map(int, input().split())
p = 10**9 + 7



def fac(n):
  x = 1
  for i in range(1,n+1):
    x *= i
  return x

nf = fac(n) % p
mf = fac(m) % p

if abs(n-m) > 1:
  ans = 0

elif n == m:
  ans = nf * mf * 2
  
else:
  ans = nf * mf
  
print(ans % p)
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n, m;
    int MOD = 1000000007;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        m = sc.nextInt();
        solve();
    }

    void solve() {
        if (n > m) {
            int temp = n;
            n = m;
            m = temp;
        }
        if (m - n > 1) {
            System.out.println(0);
            return;
        }
        long ans = 0;
        long[] facts = fillFactorial(m, MOD);
        if (n == m) {
            ans = 2 * facts[n] * facts[m] % MOD;
        } else {
            ans = facts[n] * facts[m] % MOD;
        }
        System.out.println(ans);
    }

    long[] fillFactorial(int max, int mod) {
        long[] facts = new long[max + 1];
        facts[0] = 1;
        for (int i = 1; i < facts.length; i++) {
            facts[i] = facts[i - 1] * i % mod;
        }
        return facts;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}
//  [java]
import java.util.*;

public class Main{
    final int MOD = 1000000007;
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        if(Math.abs(n - m) >= 2){
            System.out.println(0);
            return;
        }
        long out = 1;
        for(int i = 2; i <= n; i++){
            out *= i;
            if(out > MOD) out %= MOD;
        }
        for(int i = 2; i <= m; i++){
            out *= i;
            if(out > MOD) out %= MOD;
        }
        System.out.println((out * 2) % MOD);
    }


    public static void main(String[] args){
        new Main().solve();
    }
}
//  [java]
import java.util.*;

public class Main{
    final int MOD = 1000000007;
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        if(Math.abs(n - m) >= 2){
            System.out.println(0);
            return;
        }
        long out = 1;
        for(int i = 2; i <= n; i++){
            out *= i;
            if(out > MOD) out %= MOD;
        }
        for(int i = 2; i <= m; i++){
            out *= i;
            if(out > MOD) out %= MOD;
        }
        System.out.println((out % MOD) * 2 % MOD);
    }


    public static void main(String[] args){
        new Main().solve();
    }
}
//  [java]
import java.util.*;
public class Main {
    public static void main(String[] args ){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int mod = (int) Math.pow(10,9) + 7;

        if (Math.abs(m-n) > 1) {
            System.out.println(0);
            return;
        }
        long ans = 1;
        for (int i = 2; i <= n; i++) {
            ans *= i;
            ans %= mod;
        }
        for (int i = 2; i <= n; i++) {
            ans *= i;
            ans %= mod;
        }
        System.out.println(n == m ? 2 * ans % mod: ans);
    }

}
//  [cpp]
#include <cstdio>

using namespace std;

const int MOD = 1000000007;
int n, m;
int main()
{
    scanf("%d%d", &n, &m);
    if(n > m + 1 || m > n + 1) printf("0");
    else{
        if(n < m) ++n, --m;
        if(n == m){
            int f1 = 1;
            for(int i = 2; i <= n ; ++i)
                f1 = (1LL * f1 * i) % MOD;
            f1 = (1LL * f1 * f1 * 2) % MOD;
            printf("%d", f1);
        }
        else if(n > m){
            int f1 = 1;
            for(int i = 2; i <= m ; ++i)
                f1 = (1LL * f1 * i) % MOD;
            f1= (1LL *f1 * f1) % MOD;
            f1 = (1LL * f1 * n) % MOD;
            printf("%d", f1);
        }

    }
    return 0;
}
//  [cpp]
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

ll func(long n) {
    ll ans=1;
    long i;
    for(i=1; i<=n; i++) {
        ans = ans * i %MOD;
    }
    return ans;
}

int main(int argc, char* argv[])
{
    long n,m;
    scanf("%ld%ld", &n, &m);

    if(n==m) {
        printf("%lld\n", func(n) * func(n) * 2 % MOD);
    }
    else if (n==m+1) {
        printf("%lld\n", func(n) * func(m) % MOD);
    }
    else if (m==n+1) {
        printf("%lld\n", func(n) * func(m) % MOD);
    }
    else {
        printf("0\n");
    }

    return 0;
}
//  [cpp]
#include <stdio.h>
#define y 1000000007
int main(void){
  int n,m,i;
  long dog=1,mon=1,ans;
  scanf("%d%d",&n,&m);
  if (n-m>1||m-n>1){
    printf("0\n");
    return 0;
  }
  for (i=2;i<=n;i++) dog=(dog*i)%y;
  for (i=2;i<=m;i++) mon=(mon*i)%y;
  ans=dog*mon%y;
  if (n==m) ans=ans*2%y;
  printf("%ld\n",ans);
  return 0;
}
//  [cpp]
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


// 階乗mod
ll fmod(ll n){
    ll ans = 1;
    for(ll i = 1; i <= n; i++){
        ans *= i;
        ans %= MOD;
    }

    return ans;
}

int main(){
    ll N, M;
    cin >> N >> M;

    ll
    if(N == M){
        cout << (2 * fmod(N) % MOD) * fmod(M) % MOD << endl;
    }else if(abs(N - M) == 1){
        if(N < M){
            swap(N, M);
        }
        cout << fmod(N) * fmod(M) % MOD << endl;
    }else{
        cout << 0 << endl;
    }


    return 0;
}
//  [cpp]
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll INFL = 1e18;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int n,m;
    cin >> n >> m;
    long long N = 1, M = 1;
    for (int i = 1;i <= m;i++){
        M *= i;
    }
    for (int i = 1;i <= n;i++){
        N *= i;
    }
    if (abs(m-n) >= 2){
        cout << 0 << endl;
    }
    else if (abs(m-n) == 1){
        cout << M*N << endl;
        return 0;
    } else {
        cout << 2*M*N << endl;
        return 0;
    }
}
//  [cpp]
#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

ll f(ll n)
{ 
  if (n == 1) return 1;
  return ((n * f(n - 1)) % MOD);
}

void solve()
{
  int n, m;
  cin >> n >> m;
  if ( abs(n - m) > 1)
  {
    cout << 0;
    return;
  }
  ll ans = 1 + (n == m);
  ans *= f(n);
  ans *= f(m);
  cout << ans;
}

int main()
{
  fastio;
  solve();

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

int main()
{
	long long N, M;
	scanf("%lld %lld", &N, &M);
	
	long long i, dog = 1, monkey = 1;
	for (i = 2; i <= N; i++) dog = dog * i % 1000000007;
	for (i = 2; i <= M; i++) monkey = monkey * i % 1000000007;
	
	if (llabs(N - M) >= 2) printf("0\n");
	else if (llabs(N - M) == 1) printf("%lld\n", dog * monkey % 1000000007);
	else printf("%lld\n", dog * monkey * 2 % 1000000007);
	fflush(stdout);
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  if (labs(n-m) > 1) {
    printf("0\n");
    return 0;
  }
  long mod = pow(10,9)+7;
  long answer = 1;
  if (labs(n-m) == 0) {
    answer *= 2;
  }
  for (long i = 1; i <= n; i++) {
    answer *= i;
    answer %= mod;
  }
  for (long i = 1; i <= m; i++) {
    answer *= i;
    answer %= mod;
  }
  printf("%ld\n", answer);

  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

lli f[MAX];
void fact(int n) {
  for (lli i = 1; i <= n; i++ ) 
    f[i] = f[i-1] * i % MOD;
}

int main(void) {
  lli N, M;
  scanf("%lld %lld", &N, &M);

  f[0] = 1;
  fact(100000);
  lli dif = llabs(N - M);
  if ( dif != 0 && dif != 1 ) {
    printf("0\n");
    return 0;
  }
  if ( dif == 0 ) {
    printf("%lld\n", ((f[N] * f[M]) % MOD) * 2 % MOD);
    return 0;
  }
  printf("%lld\n", f[N] * f[M] % MOD);
  return 0;
}
//  [c]
#include<stdio.h>
#include<math.h>
int main()
{
long long int a,b,ans,mod,i,modp[200001];
  scanf("%lld %lld",&a,&b);
  mod=pow(10,9)+7;
  modp[0]=1;
  for(i=1;i<200001;++i)
  {
  modp[i]=(modp[i-1]*i)%mod;
  }
  ans=(modp[a]*modp[b])%mod;
  if(llabs(a-b)>1) printf("0");
  else if(a==b) printf("%lld",ans*2);
  else printf("%lld",ans);
return 0;}
//  [c]
#include<stdio.h>
#include<math.h>
int main()
{
long long int a,b,ans,mod,i,modp[200001];
  scanf("%lld %lld",&a,&b);
  mod=pow(10,9)+7;
  modp[0]=1;
  for(i=1;i<200001;++i)
  {
  modp[i]=(modp[i-1]*i)%mod;
  }
  ans=(modp[a]*modp[b])%mod;
  if(llabs(a-b)>1) printf("0");
  else printf("%lld",ans);
return 0;}
//  [c]
#include<stdio.h>
#include<math.h>
int main()
{
long long int a,b,ans,mod,i,modp[200001];
  scanf("%lld %lld",&a,&b);
  mod=pow(10,9)+7;
  modp[0]=1
  for(i=1;i<200001;++i)
  {
  modp[i]=(modp[i-1]*i)%mod;
  }
  ans=(modp[a]*modp[b])%mod;
  if(abs(a-b)>1) printf("0");
  else printf("%lld",ans);
return 0;}
//  [javascript]
"use strict";


const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    // 差が2以上あると交互に並べられない
    if(Math.abs(N - M) > 1) {
        console.log(0);
        return;
    }
    
    const MOD = 1e9 + 7;
    let answer = 1;
    
    for(let i=1; i<=N; i++) {
        answer = (answer % MOD) * (i % MOD);
    }
    
    for(let i=1; i<=M; i++) {
        answer = (answer % MOD) * (i % MOD);
    }
    
    /* -----------------------------------------------------
       差が0のときは、組み合わせが2通り 例：犬猿犬猿, 猿犬猿犬
       差が1のときは、組み合わせが1通り 例：犬猿犬猿犬
       それによって答えを2倍にするかどうか分ける
    --------------------------------------------------------*/
    console.log(answer * ((N == M) + 1) % MOD);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
'use strict'

function main(input) {
  input = input.split(' ').map(v => ~~v)
  const n = input[0]
  const m = input[1]

  const limit = 1e9 + 7 //(Math.pow(10, 9) + 7)

  //交互に並べられない
  if (Math.abs(n - m) >= 2) {
    console.log(0)
    return
  }

  let nn = 1
  for (let i = 2; i <= n; i++) {
    nn *= i
    if (nn >= limit) {
      nn = nn % limit
    }
  }
  // let mm = 1
  for (let i = 2; i <= m; i++) {
    nn *= i
    if (nn >= limit) {
      nn = nn % limit
    }
  }
  // console.log(nn,mm)

  let tmp = nn % limit
  // console.log(tmp)
  if (n == m) {
    tmp = 2 * tmp
  }
  const ans = tmp % limit

  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
"use strict";


const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    // 差が2以上あると交互に並べられない
    if(Math.abs(N - M) > 1) {
        console.log(0);
        return;
    }
    
    const MOD = 1e9 + 7;
    let answer = 1;
    
    for(let i=1; i<=N; i++) {
        answer = (answer % MOD) * (i % MOD);
    }
    
    for(let i=1; i<=M; i++) {
        answer = (answer % MOD) * (i % MOD);
    }
    
    /* -----------------------------------------------------
       差が1のときは、組み合わせが2通り 例：犬猿犬猿, 猿犬猿犬
       差が0のときは、組み合わせが1通り 例：犬猿犬猿犬
       それによって答えを2倍にするかどうか分ける
    --------------------------------------------------------*/
    console.log(answer * ((N == M) + 1) % MOD);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [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 fn = (x) => {
    let ans = 1n
    for(let i = 1n; i<=x; i++){
        ans *= i
    } 
    return ans
}
const Main = () => {
    const [n, m ] = nextIntArray()
    let ans = fn(n) * fn(m) * 2n % 1000000007n
    console.log(Number(ans))
}
Main()
//  [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 fn = (x) => {
    let ans = 1n
    for(let i = 1n; i<=x; i++){
        ans *= i
    } 
    return ans
}
const Main = () => {
    const [n, m ] = nextIntArray()
    let ans = fn(n) * fn(m) * 2n / 1000000007n
    console.log(Number(ans))
}
Main()
//  [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 fn = (x) => {
    let ans = 1n
    for(let i = 1n; i<=x; i++){
        ans *= i
    } 
    return ans
}
const Main = () => {
    const [n, m ] = nextIntArray()
    let ans = fn(n) * fn(m) * 2n
    while(ans > 1000000007n){
        ans /= 1000000007n
    }
    console.log(Number(ans))
}
Main()
//  [go]
package main

import "fmt"

const mod int = 1000000007

func main() {
	var N, M, r int
	fmt.Scan(&N, &M)

	diff := Abs(N - M)
	if diff >= 2 {
		fmt.Println(0)
		return
	}
	w := make([]int, 100010)
	w[1] = 1
	for i := 2; i < len(w); i++ {
		w[i] = (w[i-1] * i) % mod
	}
	r = (w[N] * w[M]) % mod
	if diff == 0 {
		r = (r * 2) % mod
	}
	fmt.Println(r)
}
func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
//  [go]
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const mod = 1e9 + 7

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

	N, M := getInt(), getInt()
	if abs(N-M) > 1 {
		out(0)
		return
	}
	ans := 1
	for i := 1; i <= N; i++ {
		ans *= i
		ans %= mod
	}
	for i := 1; i <= M; i++ {
		ans *= i
		ans %= mod
	}
	if N == M {
		ans *= 2
		ans %= mod
	}
	out(ans)
}
//  [go]
package main

import (
	"fmt"
)

const mod = 1000000007

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	var ans int
	if n == m {
		p := permutation(n)
		ans = 2 * p * p
	} else if abs(n-m) == 1 {
		p := permutation(min(n, m))
		ans = p * p * max(n, m)
	} else {
		ans = 0
	}
	fmt.Println(ans % mod)
}

func permutation(n int) int {
	v := 1
	for i := 0; i < n; i++ {
		v *= n - i
		v %= mod
	}
	return v
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func permutation(n int, k int) int {
	v := 1
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v *= (n - i)
			v = v % int(math.Pow10(9)+7)
		}
	} else if k > n {
		v = 0
	}
	return v
}

func factorial(n int) int {
	return permutation(n, n-1)
}

func main() {
	// Code for C - Reconciled?
	var N, M int
	fmt.Scanf("%d %d", &N, &M)

	var count int
	if N == M {
		count = count + 2
	}

	count += factorial(N)
	count += factorial(M)
	count = count % int(math.Pow10(9)+7)
	fmt.Println(count)
}
//  [go]
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	if N < M {
		N, M = M, N
	}
	var ans int
	if N-M >= 2 {
		ans = 0
	} else {
		ans = ModFactorial(N) * ModFactorial(M)
		if N == M {
			ans = ans * 2 % Mod
		}
	}
	fmt.Println(ans)
}

const Mod = int(1e9) + 7

func ModFactorial(n int) int { return fac[n] }

var fac []int

func init() {
	const MAX = 1e5
	fac = make([]int, MAX+1)
	fac[0], fac[1] = 1, 1
	for i := 2; i <= MAX; i++ {
		fac[i] = fac[i-1] * i % Mod
	}
}
//  [ruby]
def fact(n, mod)
  f = 1
  n.downto(1){|i|
    f = (f * i) % mod
  }
  f
end

N, M = gets.chomp.split(" ").map(&:to_i)
MOD = 10 ** 9 + 7

if (N-M).abs > 1 then
  puts 0
elsif N == M then
  wk = fact(N, MOD)
  puts (2 * wk * wk) % MOD
else
  w = [N, M].min
  wk = fact(w, MOD)
  puts ((w+1) * wk * wk) % MOD
end
//  [ruby]
MODS = 10**9 + 7

def mod_fact(count)
  x = 1
  2.upto(count) do |i|
    x = x * i % MODS
  end
  x
end

n, m = gets.split.map(&:to_i).minmax
case m - n
when 0
  p mod_fact(n)**2 * 2 % MODS
when 1
  p mod_fact(n)**2 * m % MODS
else
  p 0
end
//  [ruby]
NN = 1000000007

n, m = gets.chomp.split(" ").map(&:to_i)

if (n-m).abs > 1
  puts 0
  exit
end

def fact(n)
  x = 1
  for i in 2..n
    x = x * i % NN
  end
  return x
end

if n == m
  puts fact(n) ** 2 * 2 % NN
elsif n < m
  puts (fact(n) ** 2 * m) % NN
else
  puts (fact(m) ** 2 * n) % NN
end
//  [ruby]
M = 10**9+7
def ext(x)
  s = 1
  for i in 1..x
    s *= (i%M)
  end
  return s
end

n,m = gets.strip.split.map(&:to_i)
if (n-m).abs >= 2
  puts 0
  exit
end
if (n-m).abs == 1
  puts (ext(n)*ext(m))%M
  exit
end
if n == m
  puts (2*ext(n)*ext(m))%M
  exit
end
//  [ruby]
n, m = gets.chomp.split(" ").map(&:to_i)
sa = n - m
count = 1
def ans(n)
    if n > 1
        n * ans(n-1)
    else
        return 1
    end
end
if sa == 0
    ans = ans(n) * ans(n) * 2
elsif sa == 1
    ans = ans([n,m].min) * ans([n,m].max)
else
    ans = 0
end
puts ans
//  [ruby]

n=gets.split.map(&:to_i)
if n[0]==n[1]
    result=2
    for i in 1..n[0]
        result*=i
        result*=i
        result%=10**9+7
    end
    result%=10**9+7
    p result
elsif (n[0]-n[1]).abs==1
    result=1
       for i in 1..n[0]
           result*=i
           result%=10**9+7
       end
       result%=10**9+7
       p result
elsif (n[0]-n[1]).abs>1
    p 0
end
//  [rust]
use std::io::*;
const MOD: usize = 1_000_000_007;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let mut n: usize = itr.next().unwrap().parse().unwrap();
    let mut m: usize = itr.next().unwrap().parse().unwrap();
    if n < m {
        std::mem::swap(&mut n, &mut m);
    }
    if n - m > 1 {
        println!("0");
    } else {
        let mut ans = 1;
        for i in 2..m + 1 {
            ans = ans * i % MOD * i % MOD;
        }
        for i in m + 1..n + 1 {
            ans = ans * i % MOD;
        }
        if n == m {
            ans = ans * 2 % MOD;
        }
        println!("{}", ans);
    }
}
//  [rust]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    const P: i64 = 1000000007;
    const L: usize = 100010;

    let mut f: Vec<i64> = vec![0; L];

    f[0] = 1;
    f[1] = 1;
    for i in 2..L {
        f[i] = (f[i-1] * (i) as i64) % P;
    }

    let (n, m) = get!(i64, i64);
    if (n-m).abs() > 1 {
        println!(0);
        return;
    }
    if n == m {
        println!("{}", f[n as usize] * f[m as usize] % P * 2 % P);
    } else {
        println!("{}", f[n as usize] * f[m as usize] % P);
    }
}
//  [rust]
use std::io;
use std::str::FromStr;
use std::cmp::{max,min};

static MOD: u64 = 1_000_000_007;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (n, m) = input_tuple();
    let mut ans = 1;
    if n > m + 1 || m > n + 1 {
        println!("0");
        return;
    }

    for i in 1..max(n+1,m+1) {
        ans *= i;
        ans %= MOD;
        if i == min(n, m) {
            ans *= ans;
            ans %= MOD;
        }
    }
    if n == m {
        println!("{}", ans * 2 % MOD);
    } else {
        println!("{}", ans);
    }

}
//  [rust]
use proconio::input;
use std::cmp::{min, max};

fn main() {
    input! {
        m: usize,
        n: usize,
    }

    let div = 1000000007;
    let mut ans = 0;
    match max(m, n) - min(m, n) {
        0 => {
            // 差がないとき
            ans = ((power(m) % div) * (power(n) % div) % div) * 2;
        },
        1 => {
            // 差が1の時
            ans = (power(m) % div) * (power(n) % div) % div;
        },
        _ => {},
    }
    println!("{}", ans % div);
}

fn power(x: usize) -> usize {
    let mut ans = 1;
    for i in 1..=x {
        ans *= i;
    }
    ans
}
//  [rust]
use proconio::input;
use std::cmp::{min, max};

fn main() {
    input! {
        m: i128,
        n: i128,
    }

    let mut ans = 0;
    match max(m, n) - min(m, n) {
        0 => {
            // 差がないとき
            ans = power(m) * power(n) * 2;
        },
        1 => {
            // 差が1の時
            ans = power(m) * power(n);
        },
        _ => {},
    }
    println!("{}", ans % 1000000007);
}

fn power(x: i128) -> i128 {
    let mut ans = 1;
    for i in 1..=x {
        ans *= i;
    }
    ans
}
//  [rust]
use proconio::input;
use std::cmp::{min, max};

fn main() {
    input! {
        m: usize,
        n: usize,
    }

    let mut ans = 0;
    match max(m, n) - min(m, n) {
        0 => {
            // 差がないとき
            ans = power(m) * power(n) * 2;
        },
        1 => {
            // 差が1の時
            ans = power(m) * power(n);
        },
        _ => {},
    }
    println!("{}", ans % 1000000007);
}

fn power(x: usize) -> usize {
    let mut ans = 1;
    for i in 1..=x {
        ans *= i;
    }
    ans
}
//  [swift]
let i=readLine()!.characters.split(" ").map{Int(String($0))!},m=Int(1e9+7)
func f(x:Int)->Int{return (1...x).reduce(1){$0*$1%m}}
print(f(i[0])*f(i[1])*max(2-abs(i[0]-i[1]),0)%m)
//  [swift]
func factorial(x:Int)->Int{return (1...x).reduce(1){$0*$1%1000000007}}
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, M) = (input[0], input[1])
print(factorial(N)*factorial(M)*(N==M ? 2:abs(N-M)<2 ?1:0)%1000000007)
//  [swift]
let i=readLine()!.characters.split(" ").map{Int(String($0))!},m=1000000007
func f(x:Int)->Int{return (1...x).reduce(1){$0*$1%m}}
print(f(i[0])*f(i[1])*max(2-abs(i[0]-i[1]),0)%m)
//  [swift]
let i=readLine()!.characters.split(" ").map{Int(String($0))!},m=Int(1e+9)
func f(x:Int)->Int{return (1...x).reduce(1){$0*$1%m}}
print(f(i[0])*f(i[1])*max(2-abs(i[0]-i[1]),0)%m)
//  [swift]
let i=readLine()!.characters.split(" ").map{Int(String($0))!},m=1000000007
func f(x:Int)->Int{return (1...x).reduce(1){$0*$1%m}
print(f(i[0])*f(i[1])*max(2-abs(i[0]-i[1]),0)%m)
//  [typescript]
{
  const main = (input: string): void | string | number => {
    const r = _reader(input)
    const [n, m] = r.nn()

    if (Math.abs(m - n) >= 2) {
      return 0
    }
    let res = _product(m, _mod, _product(n, _mod, 1))

    if (m === n) {
      res *= 2
    }
    return res % _mod
  }
  const _mod = 10 ** 9 + 7
  const _range = (n: number) => Array.from(Array(n).keys())
  const _product = (n: number, mod, start: number) =>
    _range(n).reduce((p, c) => (p * (c + 1)) % mod, start)

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
}
//  [typescript]
{
  const main = (input: string): void | string | number => {
    const r = _reader(input)
    const [n, m] = r.nn()

    if (Math.abs(m - n) > 2) {
      return 0
    }
    let res = _product(m, _mod, _product(n, _mod, 1))

    if (m === n) {
      res *= 2
    }
    return res % _mod
  }
  const _mod = 10 ** 9 + 7
  const _range = (n: number) => Array.from(Array(n).keys())
  const _product = (n: number, mod, start: number) =>
    _range(n).reduce((p, c) => (p * (c + 1)) % mod, start)

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
}
//  [python]
S = input()

if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
else:
    print("Sunny")
//  [python]
import sys

#+++++
		
def main():
	a= ['Sunny', 'Cloudy', 'Rainy']
	a=a+a
	today = input()
	for i,w in enumerate(a):
		if w==today:
			print(a[i+1])
			return
		
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
//  [python]
a = input()
if (a == "Sunny"):
  print("Cloudy")
elif (a == "Cloudy"):
  print("Rainy")
elif (a == "Rainy"):
  print("Sunny")
//  [python]
s=input()


if s=="Sunny":
  print("Cloudy")
elif s=="Cloudy":
  print("Rainy")
elif s=="Rainy":
  print("Sunny)
//  [python]
s=str(input())
if s=='S':
  print('C')
elif s=='C':
  print('R')  
else:
  print('S')
//  [python]
n = int(input())
s = input()

def z_algorythm(s):
    n = len(s)
    LCP = [0]*n
    c = 0
    for i in range(1, n):
        if i + LCP[i-c] < c + LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and s[j] == s[i+j]:
                j += 1
                LCP[i] = j
                c = i
    LCP[0] = n
    return LCP

ans = 0
for i in range(n):
    LCP = z_algorythm(s[i:])
    for j, len in enumerate(LCP):
        tmp = min(len, j)
        ans = max(ans, tmp)
print(ans)
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * 課題C1
 *
 * @author ken2
 */
public class Main {

	/** 天気：晴れ */
	private static final String WATHER_SUNNY = "Sunny";
	/** 天気：曇り */
	private static final String WATHER_CLOUDY = "Cloudy";
	/** 天気：飴 */
	private static final String WATHER_RAINY = "Rainy";

	/**
	 * メイン処理

	 * @param args 起動引数
	 */
	public static void main(String[] args) {

		// 標準入力から今日の天気を取得
		String weather = scanTodayWeather(System.in);

		// 標準出力へ明日の天気を出力
		if (weather.equals(WATHER_SUNNY)) {
			System.out.println(WATHER_CLOUDY); // Sunny→Cloudy
		}
		if (weather.equals(WATHER_CLOUDY)) {
			System.out.println(WATHER_RAINY); // Cloudy→Rainy
		}
		if (weather.equals(WATHER_RAINY)) {
			System.out.println(WATHER_SUNNY); // Rainy→Sunny
		}
	}

	/**
	 * 今日の天気を取得
	 *
	 * @param in 入力ストリーム
	 * @return 今日の天気
	 */
	private static String scanTodayWeather(InputStream in) {
		InputStreamReader isr = new InputStreamReader(in);
		BufferedReader br = new BufferedReader(isr);
		String weather = null;
		try {
			weather = br.readLine();
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return weather;
	}
}
//  [java]

import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String a = sc.next();
        if(a.equals("Sunny")) p("Cloudy");
        else if(a.equals("Cloudy")) p("Rainy");
        else p("Sunny");
    }
    public static String stringCopy(String str) {
        StringBuilder builder = new StringBuilder();
        builder.append(str.toCharArray());
        return builder.toString();
    }
    public static <T> void p(T element) {
	System.out.println(element);
    }
    public static <T> void pp(T element) {
        System.out.print(element);
        }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Throwable {
		MyScanner sc = new MyScanner();
		String s = sc.nextString();

		switch (s) {
		case "Sunny":
			System.out.println("Cloudy");
			break;
		case "Cloudy":
			System.out.println("Rainy");
			break;
		case "Rainy":
			System.out.println("Sunny");
			break;
		default:
			break;
		}
	}

	static class MyScanner {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		public String nextString() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(nextString());
		}

		public String[] nextStringArr() throws IOException {
			return nextString().split(" ");
		}

		public Integer[] nextIntArr() throws IOException {
			String[] strArr = nextStringArr();
			Integer[] intArr = new Integer[strArr.length];
			for (int i = 0; i < strArr.length; i++) {
				intArr[i] = Integer.parseInt(strArr[i]);
			}
			return intArr;
		}
	}

}
//  [java]
import java.util.*;
public class Main {

    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
        String st = sc.next();
        String Sunny, Cloudy, Rainy;
        if(st.equals(Sunny)){
            System.out.print("Cloudy");
        }else if(st.equals(Cloudy)){
            System.out.print("Rainy");
        }else{
            System.out.print("Sunny");
        }
    }
}
//  [java]
import java.util.*;
public class main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		if(a.equals("Sunny")) {
			System.out.print("Cloudy");
		}
		if(a.equals("Cloudy")) {
			System.out.print("Rainy");
		}
		if(a.equals("Rainy")) {
			System.out.print("Sunny");
		}
	}

}
//  [java]
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String S = sc.next();
      String Q[] = {"Sunny","Cloudy","Rainy"};
      int P = Arrays.asList(Q).indexOf(S);
      if(P==2){
        System.out.println("sunny");
      }else{
        System.out.println(Q[P+1]);
      }
    }
}