// add Intersection and Negation
Main { {{
  static void p(String s){ System.out.println(s); }
  public static void main(String args[]) throws Exception {

    // to say that Node is a builtIn class
    // edu.neu.ccs.demeterf.util.Util.addBuiltIn(Node.class);
    Util.setDebug(true);

    Main m = Main.parse(System.in);
    p(" pair result ");
    Pair p = m.c.check();
    p.print();
    System.out.println(" done ");
  }
}}
}
Container { {{
Pair check() {
    return new edu.neu.ccs.demeterf.Traversal(new Check()).<Pair> traverse(this);
}
}}
}

Pair { {{
  static Pair make(int ww, int vv){
    return new Pair(ww,vv);
  }
  Pair add(int ww, int vv){
    return Pair.make(w+ww, v+vv);
  }
}} }

Check { {{
  Pair combine(Object o, Pair f, Pair r) {
    return f.add(r.w, r.v);
  }
  Pair combine(Object o, Pair f) {
    return f;
  }
  Pair combine(Element e)
    {return Pair.make(e.weight,0);}
  Pair combine(Container c, Integer i, Pair wv)
    { return wv.add(0, (wv.w>c.cap)?1:0); }
  Pair combine(Object i1)
    { return Pair.make(0,0); }
}} }


*{ void print() to * (PrintVisitor);}