### PROBLEM LINK:

**Author:** admin6

**Tester:** admin6

**Editorialist:** admin6

### DIFFICULTY:

EASY

### PREREQUISITES:

relational database

### PROBLEM:

You are given the collection of relation schemas for a database.

and your task is to build the database, in such a way that the lexicographically smallest table is build first.

### QUICK EXPLANATION:

First we need to store all the table info in a dictionary so we can easely find the lexicographically smallest table at each stage. Now take the lexicographically smallest table and apply DFS(Depth First Search), and do the same for the next lexicographically smallest table, and print if it is not visite before.

### AUTHOR’S AND TESTER’S SOLUTIONS:

Author’s solution can be found here.