// $Id: hash2.csharp,v 1.0 2002/02/14 15:01:00 dada Exp $
// http://dada.perl.it/shootout/

using System;
using System.Collections;

class App {
    public static int Main(String[] args) {        
        int n;        
        Hashtable hash1 = new Hashtable();
        Hashtable hash2 = new Hashtable();
        
        n = System.Convert.ToInt32(args[0]);
        if(n < 1) n = 1;
                
        for(int i=0; i<=9999; i++) {
            hash1.Add( "foo_" + i.ToString(), i);
        }
        
        for(int i = 0; i < n; i++) {
            IDictionaryEnumerator it = hash1.GetEnumerator();
            while(it.MoveNext()) {
                if(hash2.ContainsKey(it.Key)) {
                    int v1 = (int) hash1[it.Key];
                    int v2 = (int) hash2[it.Key];                
                    hash2[it.Key] = v1 + v2;
                } else {
                    hash2.Add(it.Key, hash1[it.Key]);
                }
            }
        }
        Console.WriteLine(hash1["foo_1"] + " " + hash1["foo_9999"] + " " + hash2["foo_1"] + " " + hash2["foo_9999"]);
        return(0);
    }
}