#C15000. Truncate Strings

    ID: 44713 Type: Default 1000ms 256MiB

Truncate Strings

Truncate Strings

You are given a list of strings and an integer \( n \). Your task is to truncate (shorten) each string so that its length is at most \( n \) characters. If a string has a length less than or equal to \( n \), it should remain unchanged. In other words, for every given string \( s \), you should output the prefix \( s[0:n] \), which is defined in \( \LaTeX \) as \( s_{truncated} = s[0:n] \).

Input Format:

  • The first line contains an integer \( T \), representing the number of strings.
  • The next \( T \) lines each contain a single string.
  • The last line contains the integer \( n \), the maximum allowed length for each string.

Output Format:

  • Print exactly \( T \) lines. Each line should contain the truncated version of the corresponding string.

Note: If \( n = 0 \), then every output line should be an empty line.

inputFormat

The input is given via stdin as follows:

  1. An integer \( T \) indicating the number of strings.
  2. \( T \) subsequent lines, each containing a string.
  3. An integer \( n \) given on the last line, which is the maximum allowed length of the strings.

outputFormat

Output exactly \( T \) lines on stdout, where each line is the truncated string corresponding to the input string. If a string's length is less than or equal to \( n \), print the string as is.

## sample
3
one
two
three
5
one

two three

</p>