1. 

/**
* FWP, Ausgew¤hlte Probleme aus dem ACM Programming Contest, SS10
* Problem: 902 Password Search
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=11&page=show_problem&problem=843
*
* @author Siegfried Ippisch
* @author Martin Lambeck
* @version 1.0, 09/06/2010
*
* Method : Strings
* Status : Accepted
* Runtime: 1.568
*/

import java.util.*;

public class Main {

private static String searchPassword(int n, String text){
Map<String, Integer> map = new HashMap<String, Integer>();
for(int i=0; i<=text.length()-n; i++){
String sub = text.substring(i, i+n);
if(map.containsKey(sub))
map.put(sub,map.get(sub)+1);
else
map.put(sub,1);
}
Map.Entry<String, Integer> result = null;
for(Map.Entry<String, Integer> e: map.entrySet()){
if(result == null || e.getValue() > result.getValue())
result = e;
}
return result.getKey();
}

public static void main(String[] args){
Scanner input = new Scanner(System.in);

while(input.hasNext()){
System.out.println(searchPassword(input.nextInt(),input.next()));
}

}

}