Donations

Skopje, before the earthquakes, was stricken by a devastating flood. A lot of people donated for the victims of the flood. The Red Cross keeps the records in a special software called "the machine".

The machine holds a list of N records, each one consisting of a name (with less than 20 characters, all lowercase English letters), amount of money the person donated 0 <= money < 2000000000, and their age 18 <= age < 100. Surprisingly, all the names and all the amounts of money in this list are unique and there is approximately the same numbers of records for each age.
 

name             money             age
---------        ---------         ---
jasmina          1200300           30
aleksandar       4567300           34
bidik            51230020          18
stefan           41231             50

 

Maria really wants to know how much money bidik donated. She is aware about only one function supported by the machine: count(expression), which returns the number (count) of records which satisfy the "condition" expression. This function takes in a EXPRESSION defined by the following rules:

     EXPRESSION: EXPRESSION OPERATOR EXPRESSION
     EXPRESSION: name COMP string
     EXPRESSION: money COMP integer
     EXPRESSION: age COMP integer
     OPERATOR: &&   |   ||
     COMP: ==  |  !=  |  <  |  >  |  >=  |  <=

where, integer is a standard integer value and string is an array of lowercase English letters (a-z). In other words, the machine can test an expression of conditions combined by operators AND (&&) and OR (||). In each condition any of the table columns mentioned above (name, age or money) is compared to a constant value. Name (being a string) can only be compared with valid string values (lowercase letters 'a'-'z'), and age and money (being numbers), can only be compared with integer values.

As an example, all of the following conditions are valid, and can be tested on the machine:

    name == emil
    name == emil && age < 20 || money >= 100
    age == 30 || name == bidik

Valid operators for comparison are: ==, !=, <, >, >=, <=. Name (being a string) can only be compared with valid string values (lowercase letters 'a'-'z') of length less than 20, and age and money (being numbers), can only be compared with integer values. AND (&&) and OR (||) are the only valid operators for grouping expressions.

Note: “AND” (&&) has a higher precedence than “OR” (||). No expression can be longer than 1000 characters. The function count checks the expression against every record and counts the number of records for which the expression is evaluated to true.

However, to protect the privacy of the donors, sometimes it does not really return the true number of records - i.e. if the true number of records is in some specific intervals, the function count returns 0 instead.

For example, if there was no privacy protection (i.e. if there were no intervals for which count returns 0 instead of the true number of records), for the list given above, the call:
    count(money > 1000000 && age < 34) would return 2.

In another example, if the interval for which the function count returns 0 instead of the true number of records is [1,1], than for the list given above, the call: (count(name == bidik && money == 51230020) would returned 0. (instead of the correct value 1)

Help Maria figure out how much money bidik donated using the function count. An explanation of the intervals for which the function doesn't return the true value is given in the last section - Subtasks.



Counting

Your program should use the following function:
     count(string expression), where expression is a string containing an EXPRESSION. This function returns the number (count) of records as explained in the problem statement.



Solution

Please implement a function findMoney that solves the given problem.
    findMoney(N). The function will get called with N (the number of records), and it should return the amount of money bidik has donated.

To help you get started, please download one of the following starter codes, instead of trying to implement the interactive calls yourself:
        [ C++ starter code ]             [ Pascal starter code ]             [ Java starter code ]



Constraints

Time limit: 1 second
Memory limit: 64 megabytes



Subtasks

For every test, 1 <= N <= 10000. Additionally:

    - In test cases worth 20 points, the function count(expression) returns the correct value for every interval.
    - In test cases worth 20 points, the function count(expression) returns 0 (instead of the correct value), if the count of records matched is in the interval [1, floor(N/8) - 1].
    - In test cases worth 20 points, the function count(expression) returns 0 (instead of the correct value), if the count of records matched is in the interval [1, floor(N/8) - 1] or in the interval [N - floor(N/8), N-1].
    - In test cases worth 40 points, the intervals are the same as in the previous subtask, but there is an additional constraint that you are only allowed to make 200 calls to the function count(expression).



 Submit your code