Plankton Food

Decide whether chained food trades starting from a surplus type can produce an unbounded amount of a needed type.

Medium6Shortest pathGraphNo attempts yetTime limit5sMemory limit256 MB

Problem

Only a few zoos can cultivate every type of plankton food they need for the sea vertebrates and invertebrates living in their aquariums. A zoo may run short of one particular kind of plankton food that is hard to obtain at the moment. At the same time it may hold a huge reserve of other food types that it has no immediate use for.

The director needs one particular type of plankton food right now, because the new aquarium with thermal vents is almost finished. Colleagues in other zoos are willing to help, and they sent in a range of offers. After many long calls the director has a complete list of every available offer. Reading it, he sees that obtaining the food he wants may take several trades. In the first step he would exchange type A, which his zoo has plenty of, for some other type B, which he does not need at all but which another zoo will exchange for some amount of type C, and so on until the last exchange brings in the type he wants.

The director cannot tell from the list whether the chain of exchanges he wants exists, so he calls in the economy vice director. She studies the list carefully and says:

"The amount of food a zoo gives in exchange is sometimes bigger and sometimes smaller than the amount it receives, and that depends on the type of the food and on how generous that zoo is. I cannot tell yet whether the chain of exchanges exists. If it does exist, then it might be possible to combine the offers so that we receive a theoretically unlimited supply of the food we want for only a small investment of the food we already have. We have to check that possibility too."

You are given the list of offers from all the other zoos. Decide whether the exchanges can be arranged so that a limited volume of the unnecessary food brings in a theoretically unlimited supply of the needed type, assuming the stocks in the other zoos are unlimited. Any exchange based on a particular offer may happen an arbitrary number of times.

Input

The input holds several test cases. Each test case starts with a line containing four positive integers TT, FF, FuF_u, FnF_n. TT is the number of trade offers and FF is the number of plankton food types. The types are labeled 1 through FF. FuF_u is the label of the unnecessary food the organizing zoo offers, and FnF_n is the label of the necessary food it wants to obtain.

Next come TT lines, one per offer. Each line holds three values FrF_r, FgF_g, UU. FrF_r and FgF_g are labels of food types. UU is the natural logarithm of the number of units of food type FgF_g that the offering zoo gives in exchange for receiving 1 unit of food type FrF_r. Logarithms are popular in zoos because of the large range of animal sizes. UU is a decimal number with at most three digits after the decimal point and with absolute value at most 1000. The identity of the offering zoo has been stripped away because it is not needed to solve the problem. TT is at most 10000 and FF is at most 5000.

The input ends with a line holding four zeros.

Output

For each test case print "TRUE" or "FALSE" on its own line. Print "TRUE" if and only if the exchanges can be arranged so that an investment of a limited volume of the unnecessary food type results in a theoretically unlimited supply of the necessary food type.