// Arup Guha
// 7/13/04
// Solution to 2004 BHCSI Words program, used to practice using String
// class.

import java.io.*;

public class Words {

  public static void main(String[] args) throws IOException {

    BufferedReader stdin = new BufferedReader
				(new InputStreamReader(System.in));

    // Get the two words.
    System.out.println("Please enter your first word.");
    String word1 = stdin.readLine();
    System.out.println("Please enter your second word.");
    String word2 = stdin.readLine();

    // Equal words - note how we check the uppercase versions, but print
    // out the originals.
    if ((word1.toUpperCase()).equals(word2.toUpperCase()))
      System.out.println("Both of the words you entered are the same.");

    // Check if word1 starts with word2.
    else if ((word1.toUpperCase()).startsWith(word2.toUpperCase()))
      System.out.println(word1+" starts with "+word2);

    // Check if word2 starts with word1.
    else if ((word2.toUpperCase()).startsWith(word1.toUpperCase()))
      System.out.println(word2+" starts with "+word1);

    // Check if word1 ends with word2.
    else if ((word1.toUpperCase()).endsWith(word2.toUpperCase()))
      System.out.println(word1+" ends with "+word2);

    // Check if word2 ends with word1.
    else if ((word2.toUpperCase()).endsWith(word1.toUpperCase()))
      System.out.println(word2+" ends with "+word1);

    // Unrelated!
    else
      System.out.println(word1+" and "+word2+" are unrelated.");
  }
}
