Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 3 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 17 Sep 2017 My Price 9.00

Sherlock Holmes

Sherlock Holmes was trying to solve another murder case. He found a box that can be unlocked only by forming a pattern on it. Box has a matrix of LEDs of N x M on the top and K switches which can toggle some LEDs on the box.

Sherlock Holmes being very smart already knew the pattern that has to be formed using the LEDs to unlock the box. He found this task a bit tedious so asks you for help. Given the size of the matrix (N x M), list of K switches and with each switch a list of position(x,y) of LEDs (0 based index) that will be toggled on turning on that particular switch, you need to tell whether pattern can be formed or not

Input

First line of input contains no. of test cases T.

And first line of each testcase contains N,M (the size of the matrix) and K (the no. of switches).

Then K lines follow, first integer of each line is P (no. of LEDs it can toggle) and then follow 2*P integers denoting the x and y coordinates of the LED (like x1 y1 x2 y2 x3 y3 …..xp yp)

Then follows the N X M matrix representing the final pattern. Each cell of the matrix will be either 1(ON) or 0(OFF)

Output

Output of each test case will be a line containing “Yes” or “No” (quotes for clarity), “Yes” if the pattern can be formed “No” if it cannot be.

Constraints

1
1
1

Note:
All the LEDs are off initially

Example

Input: 1 5 5 4 4 0 1 0 2 0 3 0 4 8 1 1 1 2 1 3 1 4 2 1 2 2 2 3 2 4 8 2 1 2 2 2 3 2 4 0 1 0 2 0 3 0 4 4 3 1 3 2 3 3 3 4 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 Output: Yes

Answers

(5)
Status NEW Posted 17 Sep 2017 05:09 AM My Price 9.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)