BNU Three Kingdoms

Source: Internet
Author: User

"Three Kingdoms" is a popular desktop game. It integrates the features of similar games in the West, and integrates the background of the Three Kingdoms period in China, uses identity as a clue, and uses cards as a form, A collection of historical, literary, and artistic elements.

I believe many people have played this game and will only give a brief introduction to this issue:

[Kill]

During the playing phase, the attack scope is used for a role other than the role itself. The effect is to cause 1 point of damage to the role.

The attack range is 1. (When calculating the distance d ≤ 1, you can use [kill ])

[Ma]

-Num [horse]

When this role is killed to calculate the distance from other roles, always-num. (It can be understood as an attack advantage ).

+ Num [horse]

When other roles exit kill and calculate the distance from this role, always + num. (It can be understood as a defense advantage ).

(A role can be equipped with a maximum of one-num1 [horse] and a maximum of one + num2 [horse], and can be equipped with two types of horse at the same time. Num1 has nothing to do with num2)

In theory, there is no limit on the number of people in the Three Kingdoms, so you have called N people to come and play together. Everyone sat in a circle and numbered 1 to n in turn counterclockwise, M operations are provided. Each operation is one of the following two types:


"N1 s num" -- indicates that players numbered N1 will be equipped or replaced with a horse ].

S is "+" or "-";

"K a B" -- indicates that a uses a [kill] to test whether a can kill B.

If yes, "Yes!" Is output! ", Otherwise output" I'm sorry .".

Zhao Yun has a pair of equipment, and there is a plus (MA ].




At this time, the distance between Zhao Yun and Guan Yu is d = 1. When Guan Yu tried to kill Zhao Yun, the distance was d = 2.

Input

The first behavior T (1 ≤ T ≤ 10) indicates the number of test data groups.

The first behavior of each group of data is two integers n, m. (2 ≤ n ≤ 1000, 1 ≤ m ≤ 1000)

Next there are m rows, each row in the format

"N1 s num" (1 ≤ N1 ≤ n, S is "+" or "-", 1 ≤ num ≤ 100, both N1 and num are integers)

Or "k a B" (1 ≤ a, B ≤ n, A = B, A, B are integers)

Assume that no one in the game is killed.

Output

For each group of data, first output a line "case # C:", C corresponds to the number of data groups, C from 1 to T.

For each operation in the format of "k a B", "Yes!" Is output! "Or" I'm sorry .".
Each group of data is followed by an empty row.

Sample Input

2

3 1

K 1 3

5 4

K 1 3

K 1 2

1-1

K 1 4

Sample output

Case #1:

Yes!


Case #2:

I'm sorry.

Yes!

Yes!

I can only express my mood without words !! A simple question simulation is theoretically easy, but this OJ is really abnormal !!

Converting a character to a number is an error. It takes me a long time to check the bug. Paste the AC code.

# Include <iostream> # include <string. h> # include <algorithm> # include <stdio. h ># include <cmath> using namespace STD; # define ABS (x) <0? 0-(x) :( X) int min (int A, int B) {return a <B? A: B;} int main () {int T, I, j, N, hash1 [1010], hash2 [1010], TT = 1, m, A, B, x; char STR [3]; CIN> T; while (t --) {printf ("case # % d: \ n", TT ++ ); scanf ("% d", & N, & M); for (I = 1; I <= N; I ++) {hash1 [I] = 0; hash2 [I] = 0;} while (M --) {scanf ("% s", STR); If (STR [0]! = 'K') {B = atoi (STR); // convert the string to a number scanf ("% S % d", STR, & X ); if (STR [0] = '-') hash1 [B] = x; else hash2 [B] = x;} else {scanf ("% d ", & A, & B); // cout <dis <"" 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.