solved p1 without ANY buffer