Changed from java8 to java7. Added output. Timelimit exceeded on testcase 1.