Algorithm title: UVA 531

Source: Internet
Author: User

Compromise

In a few months the European Currency Union would become a reality. However, to join the club, the Maastricht criteria must being fulfilled, and this isn't a trivial task for the countries (MA Ybe except for Luxembourg). To enforce that Germany would fulfill the criteria, our government has so many options (wonderful raise, taxes sell, Revalue the Gold reserves,...) That it's really hard to choose what.

Therefore the German government requires a for the following task:

Two politicians each enter their proposal of what to do. The computer then outputs the longest common subsequence of words of this occurs in both. As you can have a totally fair compromise (after all, a common sequence the words is something what both people E in mind).

Your country needs, so Your job are to write it for us.

Input specification

The input file would contain several test cases.

Each test case consists of two texts. Each text is given as a sequence of lower-case words, separated by whitespace, but with no punctuation. Words would be less than characters long. Both texts would contain less than words and would be terminated by a-line containing a single '#'.

The Input is terminated by the end of file.

Output specification

For the all test case, print the longest common subsequence of the words occuring in the two texts. If there is more than one such sequence, any one is acceptable. Separate the words by one blank. After the last word, output a newline character.

Sample Input

Die Einkommen der Landwirte
sind fuer die abgeordneten ein Buch mit sieben siegeln
um dem Abzuhelfen
Muessen D Ringend alle Subventionsgesetze verbessert werden
#
die Steuern auf Vermoegen und einkommen sollten nach-Mein
Ung der abgeordneten
Nachdruecklich erhoben werden
dazu muessen die Kontrollbefugnisse der Finanzbehoerden
Dringend verbessert werden
#

Sample Output

Die Einkommen der Abgeordneten Muessen dringend verbessert werden

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.