Page Contents

**Golden Stone Solutions Round E | Kick Start 2020**

**Golden Stone Solutions Round E | Kick Start 2020**

Leopold’s companion Kate likes stones, so he chose to give her a brilliant stone as a blessing. There are S kinds of stones numbered from 1 to S, 1 being the brilliant stone. A few sorts of stones are accessible for nothing out of pocket in different pieces of the city. The city comprises of N intersections numbered from 1 to N and M two-route boulevards between sets of unmistakable intersections. At every intersection, at least zero sorts of stones are accessible in boundless flexibly.

Shockingly, the brilliant stone isn’t accessible anyplace. Fortunately, Leopold is somewhat of a performer and realizes how to consolidate a gathering of stones and transform them into another stone. For instance, one of his plans could deliver a brilliant stone out of one silver stone and two marble stones. He could gather those stones in a portion of the intersections on the off chance that they are accessible, or he could utilize a portion of his numerous different plans to create any of those stones. Officially, Leopold has R plans, where a formula is in the structure (a1, a2, …, ak) – > b for some k ≥ 1. On the off chance that Leopold has accumulated k stones of types a1, a2, …, and ak at a specific intersection, he can decide to apply the formula and transform these stones into one stone of type b.

Leopold likes confuses substantially more than physical action, in this manner, he would not like to haul stones around the city superfluously. Conveying a stone along a road costs him one unit of vitality. Leopold can convey close to each stone in turn, in any case, he can drop off a stone at any intersection and get it later whenever.

What is the base measure of vitality Leopold must spend to deliver one brilliant stone? Leopold is exceptionally terrified of huge numbers. In the event that the appropriate response is more prominent than or equivalent to 1012, print – 1.

Information

The primary line of the info gives the quantity of experiments T. T experiments follow. The primary line of each experiment comprises of four whole numbers N, M, S, and R giving the quantity of intersections, boulevards, stone sorts, and plans, separately. The accompanying M lines depict the guide of the city. The I-th of these lines contains two unmistakable whole numbers Ui and Vi meaning the pair of intersections associated by the I-th road.

The resulting N lines portray the kinds of stones accessible in every intersection. The I-th of these lines begins with the quantity of stone kinds Ci accessible in I-th intersection followed by Ci unmistakable whole numbers in the range [2, S] listing the stone sorts. The brilliant stone is constantly numbered 1 and isn’t accessible.

The last R lines of each experiment depict Leopold’s enchantment plans. The I-th of these lines begins with the quantity of fixing stones Ki required for the I-th formula followed by Ki not really unmistakable whole numbers in the range [2, S] identifying the sorts of essential fixings. The I-th line closes with a whole number in the range [1, S], which is the kind of the subsequent stone in the wake of applying the I-th formula. For instance 3 6 5 6 3 signifies a formula that requires two stones of type 6, one stone of type 5, and produces a stone of type 3.

It is ensured that it is conceivable to create a brilliant stone in every one of the experiments.

Yield

For each experiment, yield one line containing Case #x: y, where x is the experiment number (beginning from 1) and y is the response for the experiment x, specifically, the base measure of vitality Leopold must spend to create one brilliant stone. On the off chance that the appropriate response is more noteworthy than or equivalent to 1012, print – 1.

*March Long Challenge 2021 Solutions*

*March Long Challenge 2021 Solutions*

*An Interesting Sequence ISS SOLUTION**Tree House THOUSES SOLUTION**Valid Paths VPATH SOLUTION**Modular Equation MODEQ SOLUTION**Tic Tac Toe TCTCTOE SOLUTION**Xor Equality XOREQUAL SOLUTION**Golf LKDNGOLF SOLUTION**Solubility SOLBLTY SOLUTION*

*April Long Challenge 2021 Solutions*

*April Long Challenge 2021 Solutions*

*Chef and Dice SDICE Solution**Worthy Matrix KAVGMAT Solution**Binary String MEX MEXSTR Solution**Boolean Game BOOLGAME Solution**Tree Permutations TREEPERM Solution**Destroy the EMP Chip CHAOSEMP Solution**Chef and Pair Flips PAIRFLIP Solution**String Power STRPOW Solution**Brahma and Shiva SHRINES Solution**Water Sort Puzzle (Challenge) WTRSORT Solution**World Record BOLT Solution**Strong Language SSCRIPT Solution**Valid Pair SOCKS1 Solution*

*Codechef Long Challenge Solutions*

*Codechef Long Challenge Solutions*

*February Long Challenge 2021*

*February Long Challenge 2021*

#### 1. Frog Sort Solution Codechef

#### 2. Chef and Meetings Solution Codechef

#### 3. Maximise Function Solution Codechef

#### 4. Highest Divisor Solution Codechef

#### 5. Cut the Cake Challenge Solution Codechef

#### 6. Dream and the Multiverse Solution Codechef

#### 7. Cell Shell Solution Codechef

#### 8. Multiple Games Solution Codechef

#### 9. Another Tree with Number Theory Solution Codechef

#### 10. XOR Sums Solution Codechef

#### 11. Prime Game Solution CodeChef

#### 12. Team Name Solution Codechef

### January Long Challenge 2021

**Chef and Division 3 DIVTHREE SOLUTION Code Chef****Encoded String DECODEIT SOLUTION Code Chef****Point Of Impact BILLRD SOLUTION Code Chef****Fair Elections FAIRELCT SOLUTION Code Chef****Watching CPL WIPL SOLUTION Code Chef****Chef and Ants ANTSCHEF SOLUTION Code Chef****Blackjack BLKJK SOLUTION Code Chef****And-Or Game ORAND SOLUTION Code Chef****Stack-Queue Sort (Challenge) SQSORT SOLUTION Code Chef****Expected Number of SCCs RCTEXSCC SOLUTION Code Chef****Curious Matrix CURMAT SOLUTION Code Chef****Cool Subsets COOLSBST SOLUTION Code Chef****Sequence Creation ARCRT SOLUTION Code Chef****Greedy Students GRDSTD SOLUTION Code Chef**

### November Challenge 2020 SOLUTION CodeChef

- Ada and Dishes SOLUTION ADADISH
- Iron Magnet and Wall SOLUTION FEMA2
- Magical Candy Store SOLUTION CNDYGAME
- Unusual Queries SOLUTION UNSQUERS
- Red-Black Boolean Expression SOLUTION RB2CNF
- Chef and the Combination Lock SOLUTION CHEFSSM
- Scalar Product Tree SOLUTION SCALSUM
- Connect on a Grid (Challenge) SOLUTION CONGRID

### October Lunchtime 2020 CodeChef SOLUTIONS

- AND Plus OR SOLUTION ANDOR
- Chef and Subtree MEXs SOLUTION SUBMEXS
- Chef Likes Good Sequences SOLUTION GSUB
- Cute Chef Gift SOLUTION COPAR
- Chef Is Just Throwing Random Words SOLUTION SSO
- Counting Spaghetti SOLUTION CDSUMS
- Chef and Edge Flipping SOLUTION EFLIP

*RELATED :*

- Top Best Keylogger in Python 3 Make One
*What is Hacking?**Secrets of the Deep Dark Web**CODECHEF September Lunchtime 2020 SOLUTIONS**August Lunchtime 2020 SOLUTIONS*

*Related :*

*A. Shandom Ruffle SOLUTION**B. Pear TreaP SOLUTION**C. Sneetches and Speeches 3 SOLUTION**D. The Grim Treaper SOLUTION**Y. Sneetches and Speeches 1 SOLUTION**Z. Trick or Treap SOLUTION**A. Floor Number SOLUTION CODE FORCES**B. Symmetric Matrix SOLUTION CODE FORCES**C. Increase and Copy SOLUTION CODE FORCES**D. Non-zero Segments SOLUTION CODE FORCES**E. Rock, Paper, Scissors SOLUTION CODE FORCES**F. Number of Subsequences SOLUTION CODE FORCES*

*Related :*

*Chef and Easy Queries SOLUTIONS CHEFEZQ**Covid Run SOLUTIONS CVDRUN OCTOBER CHALLENGE**Positive AND SOLUTIONS POSAND**Replace for X SOLUTIONS REPLESX**Village Road Network SOLUTIONS VILLNET**Random Knapsack SOLUTIONS RANDKNAP**D-Dimensional MST SOLUTIONS DDIMMST**Compress all Subsegments SOLUTIONS SEGCOMPR**Adding Squares SOLUTIONS ADDSQURE**Inversions SOLUTIONS INVSMOD2 OCOTBER CHALLENGE**Rooted Minimum Spanning Tree SOLUTIONS ROOTMST*