eolymp
bolt
Try our new interface for solving problems
Məsələlər

Kids in a Friendly Class

Kids in a Friendly Class

Kevin resembles his class in primary school. There were girls and boys in his class. Some of them were friends, some were not. But if one person considered another person a friend, the opposite was also true. Interestingly, every girl had exactly \textbf{a} friends among girls and exactly \textbf{b} friends among boys, whereas every boy had exactly \textbf{c} friends among girls and exactly \textbf{d} friends among boys. Kevin does not remember the size of his class. Help him reconstruct the class with minimal possible number of kids, such that the above conditions are satisfied. \InputFile The only line contains four integers \textbf{a}, \textbf{b}, \textbf{c}, and \textbf{d} (\textbf{1} ≤ \textbf{a}, \textbf{b}, \textbf{c}, \textbf{d} ≤ \textbf{50}). \OutputFile Output an example of a class of minimal possible size satisfying the above conditions. The first line should contains two positive integers: \textbf{m} --- the number of girls, and \textbf{n} --- the number of boys. Let’s assign numbers \textbf{1} through \textbf{m} to the girls and \textbf{m+1} through \textbf{m+n} to the boys. Each of the next lines should contain a pair of distinct integers describing a pair of friends by their numbers. Each pair of friends should appear exactly once in this list. \textit{\textbf{Note}}: The class from the example output is shown below: \includegraphics{https://static.e-olymp.com/content/a6/a6e4b1335fe136469f4ebabde6f872b4351d210d.jpg}
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 256 MiB
Giriş verilənləri #1
1 2 1 2
Çıxış verilənləri #1
2 4
1 2
3 4
4 5
5 6
6 3
1 3
1 4
2 5
2 6
Mənbə ACM ICPC 2013–2014, NEERC, Northern Subregional Contest, St Petersburg, October 26, 2013