utilized exceptionally cutting edge innovation to construct the cannons, the cannons turn each second. As such, if the I-th gun is pointing towards the city x at some second, it will focus on the city (x+1)modn at the following second.    As their name proposes, transport cannons are

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Correct answer will be upvoted else downvoted.

 

AaParsa utilized exceptionally cutting edge innovation to construct the cannons, the cannons turn each second. As such, if the I-th gun is pointing towards the city x at some second, it will focus on the city (x+1)modn at the following second. 

 

As their name proposes, transport cannons are for transportation, explicitly for human vehicle. On the off chance that you utilize the I-th cannon to dispatch yourself towards the city that it's at present pointing at, you'll be airborne for ci seconds prior to arriving at your objective. 

 

On the off chance that you actually don't get it, utilizing the I-th gun at the s-th second (utilizing which is just conceivable in case you are at present in the city simulated intelligence) will shoot you to the city (bi+s)modn and you'll land in there after ci seconds (so you'll be there in the (s+ci)- th second). Additionally note the gun that you at first dispatched from will pivot each second however you clearly will not alter course while you are airborne. 

 

AaParsa needs to utilize the guns for going between Shaazzzland's urban areas in his fabulous arrangement, and he can begin going at second 0. For him to completely use them, he has to know the base number of seconds needed to arrive at city u from city v utilizing the guns for each pair of urban areas (u,v). 

 

Note that AaParsa can remain in a city however long he needs. 

 

Input 

 

The principal line contains two integers n and m (2≤n≤600,n≤m≤n2) — the number of urban areas and guns correspondingly. 

 

The I-th line of the accompanying m lines contains three integers computer based intelligence, bi and ci (0≤ai,bi≤n−1,1≤ci≤109), signifying the gun in the city artificial intelligence, which is at first highlighting bi and going by which requires ci seconds. 

 

It is ensured that every one of the n urban areas has something like one vehicle gun planted inside it, and that no two guns from a similar city are at first pointing at a similar city (that is, all sets (ai,bi) are unmistakable). 

 

Output 

 

Print n lines, each line ought to contain n integers. 

The j-th integer in the I-th line ought to be equivalent to the base time needed to arrive at city j from city I.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education