All Tracks Algorithms String Algorithms String Searching Problem

Playful String
Tag(s):

Easy

Problem
Editorial
Analytics

KillCode is trying to learn strings but failing to solve the recursive approach given by his Teacher. His Teacher gave him a string consisting of lower case alphabetes only , He asked to find a substring in the given string after removing any charaters from the original string . For example if the string is

" Cypher"

and the substring is "yer", Killcode can remove p,h from the string and can form the given substring.

Now the Teacher got impressed from Killcode and decided to increase the difficulty by asking to find the substring and reverse of substring in given string. If both substring can be formed by a given string by removing certain characters , print "GOOD STRING " else print "BAD STRING".

Contraints

1<=t<=10 1<=|s|<=100000

Input -

First line contains integer t denoting the test cases, each test case contains two lines containing two strings.

Output-

Print "GOOD STRING"(without quotes) both strings can be formed by given string else print "BAD STRING".

SAMPLE INPUT
3
abta
aba
oley
le
tereo
re
SAMPLE OUTPUT
GOOD STRING
BAD STRING
GOOD STRING
Explanation

Test case 1: "abta" is given string and "aba" is given substring , now Killcode will remove 't' from given string and will get both substring and reverse of sub-string.

Test case 2: Killcode cannot find the substring and reverse of of sub-string after removing any charaters.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic, Kotlin

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

Notifications
View All Notifications