Exact solution of the staircase and row-convex polygon perimeter and area generating function