Tree based solution for 411 (runs in 2m30s, I need a faster computer...).