#P10691. [SNCPC2024] chmod

[SNCPC2024] chmod

Problem Description

chmod\text{chmod} is a command used to change file or directory permissions. It is one of the commonly used commands in Linux and other Unix-like operating systems. The chmod\text{chmod} command allows users to set different permissions for files or directories, to control who can read, write, or execute them.

In a Linux system, each file or directory has associated permissions, which decide what operations different users can perform on the file. Users are divided into three categories: owner, group, and others. Each category has three kinds of permissions: read (r), write (w), and execute (x). These 99 permissions can be specified separately. We call a permission string a string of length 99, whose characters in order correspond to the above 99 permissions. If the permission is granted, it is the corresponding one of r\text{r}, w\text{w}, x\text{x}; otherwise it is -\text{-}.

For example, the permission string rwxr-x--x\text{rwxr-x-}\text{-x} means that the file has all permissions for the owner, only read and execute permissions for users in the group, and only execute permission for others.

When using the chmod\text{chmod} command, you can provide a mode string to modify permissions. In this problem, we only consider mode strings of length 33 consisting of digits not greater than 77. The three digits from left to right represent the permissions of the owner, group, and others, respectively. For each digit, its lowest three binary bits from high to low indicate whether this category of users has read (r), write (w), and execute (x) permissions.

For example, after executing chmod 760 file.txt\text{chmod 760 file.txt}, the file’s permission string is rwxrw----\text{rwxrw-}\text{-}\text{-}\text{-}.

Given several valid mode strings, each time you read one mode string, you need to output the updated file’s permission string.

Input Format

The first line contains a positive integer TT (1T1001 \le T \le 100), which indicates the number of test cases.

Then follow TT lines, each containing one chmod\text{chmod} mode string.

Output Format

Output TT lines in total, where each line is the permission string corresponding to the given mode string.

3
356
114
514

-wxr-xrw-
--x--xr--
r-x--xr--

Hint

Translated by ChatGPT 5