#C6374. String Rotation

    ID: 50127 Type: Default 1000ms 256MiB

String Rotation

String Rotation

You are given a string s and an integer n. Your task is to rotate the string in a circular fashion. If n is positive, rotate the string to the right n times; if n is negative, rotate the string to the left |n| times. The effective number of rotations is computed as \( n \mod |s| \), where \(|s|\) is the length of the string.

For example:

  • For s = "hello" and n = 2, the rotated string is lohel.
  • For s = "abcdef" and n = -3, the rotated string is defabc.

Implement a program that reads the string and the integer from standard input and prints the rotated string to standard output.

inputFormat

The input consists of two lines:

  1. The first line contains the string s.
  2. The second line contains an integer n, indicating the number of rotations. A positive n indicates a right rotation, and a negative n indicates a left rotation.

outputFormat

Output the rotated string to standard output.

## sample
hello
2
lohel