This page is still under construction.

Parts of this page are still being built. What you see may change.

Simple Polygon

Time limit1sMemory limit512 MB

Summary
Given a perimeter l and area s, construct a simple rectilinear polygon with exactly that perimeter and area, or report that none exists.
Level

Hard8 of 10

Topics
Geometry, Math, Implementation, Brute force
Solved
No attempts yet

Problem

Although bobo is truly smart, he just wants you to find a simple polygon for him. The polygon you are going to find should satisfy the following conditions.

  1. The polygon is simple. That is to say, any two non-adjacent edges won't intersect or touch and any two adjacent edges have exactly one common point.
  2. Edges of the polygon are parallel to either the xx-axis or the yy-axis.
  3. The perimeter of the polygon equals ll, while the area equals ss.

Input

First line of the input contains two integers ll and ss (4≤l≤109,1≤s≤1094 \leq l \leq 10^9, 1 \leq s \leq 10^9).

Output

The first line contains an integer nn, which denotes the number of vertices of the polygon you have found (4≤n≤10004 \leq n \leq 1000).

Each of the following nn lines contains 22 integers x_i,y_ix\_i, y\_i, which denote the coordinates of points (in clockwise or counter-clockwise order) (0≤x_i,y_i≤1090 \leq x\_i, y\_i \leq 10^9).

Any appropriate solution will get accepted.

If no such polygon can be found, simply print "-1".

Examples2

  1. Example 1

    Input
    4 1
    
    Expected output
    4
    0 0
    1 0
    1 1
    0 1
    
  2. Example 2

    Input
    4 2
    
    Expected output
    -1