{"problem":{"name":"A. Comunicating the Tibet","description":{"content":"The Himalayas form the highest mountain range in the world (with mountains as high as 7,200 meters). Located in Asia, this mountain system has parts in the Bhutan, China, India, Nepal, and Pakistan. I","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":524288},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10149A"},"statements":[{"statement_type":"Markdown","content":"The Himalayas form the highest mountain range in the world (with mountains as high as 7,200 meters). Located in Asia, this mountain system has parts in the Bhutan, China, India, Nepal, and Pakistan. In China, the Tibet is a region delimited by the Himalayas.\n\nThe Tibet, which is the highest region on Earth, is an autonomous region inside the People's Republic of China. In this region there are Buddhist temples with Tibetan monks, which are visited every year by many people from the whole world. To facilitate communication, the Central Tibetan Administration (ACT, in Portuguese) wishes to install some radio-frequency antennas around the Tibet. The ACT considered the N most important temples where they wish to install these antennas. The World Communication Association (ACM, in Portuguese) was hired to setup and configure these antennas at the temples. ACM charged their star engineer Mashiro \"thunderstorm\" Sanae with this job.\n\nAfter reading about the history and customs of Tibetan monks, Mashiro found a curious fact: the Tibetans have a particular fixation for the number K. By studying the map with the location of the N temples, Mashiro noticed that if he walks through distinct temples until he returns to the starting one, the number of temples he goes through (including the first) never has the form mK + 1 for any nonnegative integer m. He was fascinated with his discovery, and realized the importance of the number K for Tibetans. Mashiro knows that, when setting up the antennas, neighboring temples should receive distinct frequencies to avoid interference. Having this constraint in mind and knowing the importance of the number K for the Tibetans, Mashiro wishes to find an assignment of frequencies to antennas that uses at most K distinct frequencies, or determine that this assignment is impossible.\n\nMashiro had an idea to solve this problem and has already started coding it. Can you beat him to it?\n\nThe first line has three integers, N, M, and K, the number of temples, the number of paths that join neighboring temples and the special number revered by the Tibetan people, respectively. The temples are represented by numbers from 1 to N.\n\nThe next M lines contain two distinct integers each. Each pair of integers represents two neighboring temples. No two lines among these M lines contain the same pair of integers.\n\nIf there is no possible frequency assignment to the temples, print a line containing \"-1\" (without the double quotes). Otherwise, print N lines. The i-th line must contain a single integer, fi, the frequency assigned to temple i, where 1 ≤ fi ≤ K. If there is more than one solution, any one will do.\n\n## Input\n\nThe first line has three integers, N, M, and K, the number of temples, the number of paths that join neighboring temples and the special number revered by the Tibetan people, respectively. The temples are represented by numbers from 1 to N.The next M lines contain two distinct integers each. Each pair of integers represents two neighboring temples. No two lines among these M lines contain the same pair of integers.  1 ≤ N ≤ 5·104  0 ≤ M ≤ 5·105  1 ≤ K ≤ N  1 ≤ fi ≤ K \n\n## Output\n\nIf there is no possible frequency assignment to the temples, print a line containing \"-1\" (without the double quotes). Otherwise, print N lines. The i-th line must contain a single integer, fi, the frequency assigned to temple i, where 1 ≤ fi ≤ K. If there is more than one solution, any one will do.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, T\\} $:  \n- Let $ N_k \\in \\mathbb{Z} $ be the number of channels.  \n- Let $ C_k = \\{(S_{k,i}, F_{k,i}) \\mid i \\in \\{1, \\dots, N_k\\}\\} $ be the set of channel-frequency pairs, where:  \n  - $ S_{k,i} \\in \\Sigma^* $ is a non-empty string of lowercase English letters ($|\\Sigma| \\leq 50$),  \n  - $ F_{k,i} \\in \\mathbb{Z} $ is the frequency ($11111 \\leq F_{k,i} \\leq 99999$).  \n\n**Constraints**  \n1. $ 1 \\leq T \\leq 100 $  \n2. For each $ k \\in \\{1, \\dots, T\\} $:  \n   - $ 1 \\leq N_k \\leq 10^4 $  \n   - $ 11111 \\leq F_{k,i} \\leq 99999 $ for all $ i \\in \\{1, \\dots, N_k\\} $  \n\n**Objective**  \nFor each test case $ k $, find the frequency $ f^*_k $ that maximizes the count of channels with that frequency.  \nIf multiple frequencies achieve the maximum count, choose the smallest such frequency:  \n$$\nf^*_k = \\arg\\min_{f \\in \\text{Freq}_k} \\left\\{ f \\,\\middle|\\, \\max_{f' \\in \\text{Freq}_k} \\left| \\left\\{ i \\in \\{1, \\dots, N_k\\} \\mid F_{k,i} = f' \\right\\} \\right| \\right\\}\n$$  \nwhere $ \\text{Freq}_k = \\{ F_{k,i} \\mid i \\in \\{1, \\dots, N_k\\} \\} $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10149A","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}