Boundary conditions

I want to select particular nodes in my 2D mesh to apply boundary conditions and traction. I saw the examples where the entire left face have been selected.

My mesh looks like this. I want to apply constraint in node 1 and 8. In node 1 both x and y displacements are restricted and in node 8 only x displacement is restricted. Can someone help?mesh