Welcome to ZOJ
Information
Problems
Runs
Statistics
Ranklist
Clarification
104 - The 11th Zhejiang University Programming Contest - D
Duck Typing

Time Limit: 2 Seconds      Memory Limit: 65536 KB

If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck.

When I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck.

In computer programming with object-oriented programming languages, duck typing is a style of dynamic typing in which an object's current set of methods and properties determines the valid semantics, rather than its inheritance from a particular class or implementation of a specific interface.

Given a chunk of code, your task is to tell the function of each statement. Each statement is a line of one of the following formats:

  • begin. This is always the first statement of the code.
  • end. This is always the last statement of the code.
  • class ClassName[:Super]. Define a new class ClassName, with its superclass being Super if specified. If ClassName has been defined or Super has not been defined before, then ignore this statement and print "oops!". Otherwise, print "class ClassName[:Super]".
  • def ClassName.MethodName. Define a method named MethodName in class ClassName. If ClassName has never been defined, then ignore this statement and print "oops!". If this method has already been defined before, then print "redef ClassName.MethodName". Otherwise print "def ClassName.MethodName".
  • undef ClassName.MethodName. If this method has not been defined or the class has not been defined, then ignore this statement and print "oops!". Otherwise, print "undef ClassName.MethodName" and this method is treat as if it has never been defined from now on.
  • call ClassName.MethodName. Call the method ClassName.MethodName according the following principle. If the method ClassName.MethodName is defined, then invoke this method. If the class ClassName has superclass Super, then check its superclass recursively until the method is defined or there are no superclasses. Print the actual method invoked "invoke ActualClassName.MethodName" or ignore this statement and print "oops!".

All ClassName and MethodName are valid identifiers, namely a sequence of one or more ASCII letters, digits (these may not appear as the first character), and underscores. Both the length of the identifier and the depth of inheritance tree don't exceed 20.

Input

There are multiple test cases. The first line of input is an integer T ≈ 10 indicating the number of test cases.

Each test case is a chunk of code. There is a blank line after each test case.

Output

For each statement, output as the description says. Output a blank line after each test case.

Sample Input

3
begin
class Sub:Super
class Super
class Sub:Super
end

begin
class Class
call Class.Method
def Class.Method
call Class.Method
end

begin
class Super
class Sub:Super
def Super.Method
call Sub.Method
end

Sample Output

oops!
class Super
class Sub:Super

class Class
oops!
def Class.Method
invoke Class.Method

class Super
class Sub:Super
def Super.Method
invoke Super.Method

References


Author: Local Contests 2011 Committee
Contest: The 11th Zhejiang University Programming Contest
Submit    Status