first solver code