🏡 index : github.com/captn3m0/codechef.git

---
{"category_name":"easy","problem_code":"FILLGRID","problem_name":"The Grid Fill Problem","problemComponents":{"constraints":"- $1 \\leq T \\leq 10$\n- $2 \\leq N \\leq 500$\n","constraintsState":true,"subtasks":"","subtasksState":false,"inputFormat":"- First line will contain $T$, number of testcases. Then the testcases follow.\n- Each testcase contains a single integer $N$\n","inputFormatState":true,"outputFormat":"- For each test case, print the grid of size $N$ $\\times$ $N$ . Print $N$ lines where each line will contain $N$ integers ( $1$ or $-1$ ) separated by a space.","outputFormatState":true,"sampleTestCases":{"0":{"id":1,"input":"2\n2\n3","output":"-1 -1\n-1 -1 \n1 -1 1\n-1 1 1\n1 1 -1","explanation":"**Test Case $1$:** \nConsider the given output :\n- For each row, sum of the elements is $-2$. \n- For each column, sum of the elements is $-2$.\n- For each row, product of the elements is $1$.\n- For each column, product of the elements is $1$. \n\nClearly, both the conditions are satisfied.\n\n**Test Case $2$:** \nConsider the given output :\n- For each row, sum of the elements is $1$. \n- For each column, sum of the elements is $1$.\n- For each row, product of the elements is $-1$.\n- For each column, product of the elements is $-1$. \n\nClearly, both the conditions are satisfied.","isDeleted":false}}},"video_editorial_url":"https://youtu.be/f0Xdhu_0nbU","languages_supported":{"0":"CPP14","1":"C","2":"JAVA","3":"PYTH 3.6","4":"CPP17","5":"PYTH","6":"PYP3","7":"CS2","8":"ADA","9":"PYPY","10":"TEXT","11":"PAS fpc","12":"NODEJS","13":"RUBY","14":"PHP","15":"GO","16":"HASK","17":"TCL","18":"PERL","19":"SCALA","20":"LUA","21":"kotlin","22":"BASH","23":"JS","24":"LISP sbcl","25":"rust","26":"PAS gpc","27":"BF","28":"CLOJ","29":"R","30":"D","31":"CAML","32":"FORT","33":"ASM","34":"swift","35":"FS","36":"WSPC","37":"LISP clisp","38":"SQL","39":"SCM guile","40":"PERL6","41":"ERL","42":"CLPS","43":"ICK","44":"NICE","45":"PRLG","46":"ICON","47":"COB","48":"SCM chicken","49":"PIKE","50":"SCM qobi","51":"ST","52":"SQLQ","53":"NEM"},"max_timelimit":0.5,"source_sizelimit":50000,"problem_author":"utkarsh_adm","problem_tester":"","date_added":"12-09-2021","tags":{"0":"simple","1":"start11","2":"utkarsh_adm"},"problem_difficulty_level":"Unavailable","best_tag":"","editorial_url":"https://discuss.codechef.com/problems/FILLGRID","time":{"view_start_date":1631727002,"submit_start_date":1631727002,"visible_start_date":1631727002,"end_date":1735669800},"is_direct_submittable":false,"problemDiscussURL":"https://discuss.codechef.com/search?q=FILLGRID","is_proctored":false,"visitedContests":{},"layout":"problem"}
---
You are given a $N$ $\times$ $N$ grid. You need to fill each cell of the grid with $1$ or $-1$. You need to fill the grid in a way such that the following conditions are met :-

- For **every** column - (Sum of values present in the column) x (Product of values present in the column) < $0$
- For **every** row - (Sum of values present in the row) x (Product of values present in the row) < $0$

It is guaranteed that there exists at least one way to fill the grid under given constraints such that both the conditions are satisifed. If there exists multiple ways to fill the grid by satisfying both the conditions, you can print any.
<aside style='background: #f8f8f8;padding: 10px 15px;'><div>All submissions for this problem are available.</div></aside>