ALPHAR - Alphabetic Relation

no tags 


Problem Statement:

Guitar is the most popular musical instrument in the world. There are some relation between notes & chords. Combinations of some notes create a chord and combining some chords create a song. When some chords make a song then the relation is created. Generally chords are expressed with some English alphabets. Always the sequence of chords will repeat in a circle of chords among A → B → C → D → E → F → G. To create a song at most 2 chords are essential. The relations among these some chords are generally called chord relation but i named this relation as Alphabetic Relation. My friend Anjan is a good guitarist. He wants to play the song in different chords rather playing the song in the original chords but maintains the sequence of original chords relation.

Input:

Assume that all the Character is in uppercase (A-Z). 

The first line of the input contains an integer T (0 < T < 1000) number of test cases. Two input in every test case. First input S ( 2 < length of S < 5000001 ) string that indicates the relation of original song chords and second input is character C that indicates which chord Anjan want to start the song. Assume that all the Character is in uppercase (A-Z)

Output:

For each case, print the case number and the Alphabetic relation (or chord relation what you say) of C which chords Anjan wants to play then print two new line.

Sample Input/Output:

 

Sample Input

Sample Output

 3

 DGA

 E

 ABC

 D

 CFG

 A

 Case 1: EAB

 Case 2: DEF

 Case 3: ADE



___________________________________________________________________________________________________________
Problem Setter: Shipu Ahamed Cool, Dept. of CSE 

Bangladesh University of Business and Technology (BUBT)


hide comments
nadstratosfer: 2018-06-27 10:31:19

Print an empty line between consecutive testcases.

Eduardo Nunes: 2013-07-03 18:31:57

@naruto, no, only capital letters. Pay attention to the output format ;D

nani: 2013-07-03 18:31:57

Last edit: 2014-01-24 10:55:19

Added by:Shipu Ahamed
Date:2013-04-04
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Guitar Chord Relation