Problem: Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order. 

After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!

She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.

Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.

Input

The first line contains an integer n (1 ≤ n ≤ 100): number of names.

Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.

Output

If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).

Otherwise output a single word "Impossible" (without quotes).

Examples

Input

3
rivest
shamir
adleman


Output

bcdefghijklmnopqrsatuvwxyz


Input

10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer


Output

Impossible


Input

10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever


Output

aghjlnopefikdmbcqrstuvwxyz


Input

7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck


Output

acbdefhijklmnogpqrstuvwxyz

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.io.BufferedInputStream;
import java.net.URL;
import java.util.Scanner;
import java.util.InputMismatchException;
import java.util.Random;
import java.net.URLConnection;
import java.util.Locale;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Iterator;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            String[] s = new String[n];
            for (int i = 0; i < n; i++) s[i] = in.next();
            Digraph g = new Digraph(26);
            for (int i = 0; i < n - 1; i++) {
                String s1 = s[i];
                String s2 = s[i + 1];
                boolean f = false;
                for (int j = 0; j < Math.min(s1.length(), s2.length()); j++) {
                    if (s1.charAt(j) != s2.charAt(j)) {
                        g.addEdge(s1.charAt(j) - 'a', s2.charAt(j) - 'a');
                        f = true;
                        break;
                    }
                }
                if (!f && s1.length() > s2.length()) {
                    out.println("Impossible");
                    return;
                }
            }
            Topological topological = new Topological(g);
            Iterable<Integer> order = topological.order();
            if (topological.hasOrder()) {
                char[] res = new char[26];
                char i = 0;
                for (int o : order) {
                    res[i++] = (char) ('a' + o);
                }
                out.println(res);
            } else {
                out.println("Impossible");
            }
        }

    }

    static final class StdOut {
        private static final String CHARSET_NAME = "UTF-8";
        private static PrintWriter out;

        // this is called before invoking any methods
        static {
            try {
                out = new PrintWriter(new OutputStreamWriter(System.out, CHARSET_NAME), true);
            } catch (UnsupportedEncodingException e) {
                System.out.println(e);
            }
        }

        private StdOut() {
        }

        public static void println(Object x) {
            out.println(x);
        }

    }

    static class Digraph {
        private static final String NEWLINE = System.getProperty("line.separator");
        private final int V;
        private int E;
        private Bag<Integer>[] adj;
        private int[] indegree;

        public Digraph(int V) {
            if (V < 0) throw new IllegalArgumentException("Number of vertices in a Digraph must be nonnegative");
            this.V = V;
            this.E = 0;
            indegree = new int[V];
            adj = (Bag<Integer>[]) new Bag[V];
            for (int v = 0; v < V; v++) {
                adj[v] = new Bag<Integer>();
            }
        }

        public Digraph(In in) {
            try {
                this.V = in.readInt();
                if (V < 0) throw new IllegalArgumentException("number of vertices in a Digraph must be nonnegative");
                indegree = new int[V];
                adj = (Bag<Integer>[]) new Bag[V];
                for (int v = 0; v < V; v++) {
                    adj[v] = new Bag<Integer>();
                }
                int E = in.readInt();
                if (E < 0) throw new IllegalArgumentException("number of edges in a Digraph must be nonnegative");
                for (int i = 0; i < E; i++) {
                    int v = in.readInt();
                    int w = in.readInt();
                    addEdge(v, w);
                }
            } catch (NoSuchElementException e) {
                throw new IllegalArgumentException("invalid input format in Digraph constructor", e);
            }
        }

        public Digraph(Digraph G) {
            this(G.V());
            this.E = G.E();
            for (int v = 0; v < V; v++)
                this.indegree[v] = G.indegree(v);
            for (int v = 0; v < G.V(); v++) {
                // reverse so that adjacency list is in same order as original
                Stack<Integer> reverse = new Stack<Integer>();
                for (int w : G.adj[v]) {
                    reverse.push(w);
                }
                for (int w : reverse) {
                    adj[v].add(w);
                }
            }
        }

        public int V() {
            return V;
        }

        public int E() {
            return E;
        }

        private void validateVertex(int v) {
            if (v < 0 || v >= V)
                throw new IllegalArgumentException("vertex " + v + " is not between 0 and " + (V - 1));
        }

        public void addEdge(int v, int w) {
            validateVertex(v);
            validateVertex(w);
            adj[v].add(w);
            indegree[w]++;
            E++;
        }

        public Iterable<Integer> adj(int v) {
            validateVertex(v);
            return adj[v];
        }

        public int indegree(int v) {
            validateVertex(v);
            return indegree[v];
        }

        public String toString() {
            StringBuilder s = new StringBuilder();
            s.append(V + " vertices, " + E + " edges " + NEWLINE);
            for (int v = 0; v < V; v++) {
                s.append(String.format("%d: ", v));
                for (int w : adj[v]) {
                    s.append(String.format("%d ", w));
                }
                s.append(NEWLINE);
            }
            return s.toString();
        }

    }

    static class EdgeWeightedDigraph {
        private static final String NEWLINE = System.getProperty("line.separator");
        private final int V;
        private int E;
        private Bag<DirectedEdge>[] adj;
        private int[] indegree;

        public EdgeWeightedDigraph(int V) {
            if (V < 0) throw new IllegalArgumentException("Number of vertices in a Digraph must be nonnegative");
            this.V = V;
            this.E = 0;
            this.indegree = new int[V];
            adj = (Bag<DirectedEdge>[]) new Bag[V];
            for (int v = 0; v < V; v++)
                adj[v] = new Bag<DirectedEdge>();
        }

        public EdgeWeightedDigraph(int V, int E) {
            this(V);
            if (E < 0) throw new IllegalArgumentException("Number of edges in a Digraph must be nonnegative");
            for (int i = 0; i < E; i++) {
                int v = StdRandom.uniform(V);
                int w = StdRandom.uniform(V);
                double weight = 0.01 * StdRandom.uniform(100);
                DirectedEdge e = new DirectedEdge(v, w, weight);
                addEdge(e);
            }
        }

        public EdgeWeightedDigraph(In in) {
            this(in.readInt());
            int E = in.readInt();
            if (E < 0) throw new IllegalArgumentException("Number of edges must be nonnegative");
            for (int i = 0; i < E; i++) {
                int v = in.readInt();
                int w = in.readInt();
                validateVertex(v);
                validateVertex(w);
                double weight = in.readDouble();
                addEdge(new DirectedEdge(v, w, weight));
            }
        }

        public EdgeWeightedDigraph(EdgeWeightedDigraph G) {
            this(G.V());
            this.E = G.E();
            for (int v = 0; v < G.V(); v++)
                this.indegree[v] = G.indegree(v);
            for (int v = 0; v < G.V(); v++) {
                // reverse so that adjacency list is in same order as original
                Stack<DirectedEdge> reverse = new Stack<DirectedEdge>();
                for (DirectedEdge e : G.adj[v]) {
                    reverse.push(e);
                }
                for (DirectedEdge e : reverse) {
                    adj[v].add(e);
                }
            }
        }

        public int V() {
            return V;
        }

        public int E() {
            return E;
        }

        private void validateVertex(int v) {
            if (v < 0 || v >= V)
                throw new IllegalArgumentException("vertex " + v + " is not between 0 and " + (V - 1));
        }

        public void addEdge(DirectedEdge e) {
            int v = e.from();
            int w = e.to();
            validateVertex(v);
            validateVertex(w);
            adj[v].add(e);
            indegree[w]++;
            E++;
        }

        public Iterable<DirectedEdge> adj(int v) {
            validateVertex(v);
            return adj[v];
        }

        public int indegree(int v) {
            validateVertex(v);
            return indegree[v];
        }

        public String toString() {
            StringBuilder s = new StringBuilder();
            s.append(V + " " + E + NEWLINE);
            for (int v = 0; v < V; v++) {
                s.append(v + ": ");
                for (DirectedEdge e : adj[v]) {
                    s.append(e + "  ");
                }
                s.append(NEWLINE);
            }
            return s.toString();
        }

    }

    static class DepthFirstOrder {
        private boolean[] marked;
        private int[] pre;
        private int[] post;
        private Queue<Integer> preorder;
        private Queue<Integer> postorder;
        private int preCounter;
        private int postCounter;

        public DepthFirstOrder(Digraph G) {
            pre = new int[G.V()];
            post = new int[G.V()];
            postorder = new Queue<Integer>();
            preorder = new Queue<Integer>();
            marked = new boolean[G.V()];
            for (int v = 0; v < G.V(); v++)
                if (!marked[v]) dfs(G, v);

            assert check();
        }

        public DepthFirstOrder(EdgeWeightedDigraph G) {
            pre = new int[G.V()];
            post = new int[G.V()];
            postorder = new Queue<Integer>();
            preorder = new Queue<Integer>();
            marked = new boolean[G.V()];
            for (int v = 0; v < G.V(); v++)
                if (!marked[v]) dfs(G, v);
        }

        private void dfs(Digraph G, int v) {
            marked[v] = true;
            pre[v] = preCounter++;
            preorder.enqueue(v);
            for (int w : G.adj(v)) {
                if (!marked[w]) {
                    dfs(G, w);
                }
            }
            postorder.enqueue(v);
            post[v] = postCounter++;
        }

        private void dfs(EdgeWeightedDigraph G, int v) {
            marked[v] = true;
            pre[v] = preCounter++;
            preorder.enqueue(v);
            for (DirectedEdge e : G.adj(v)) {
                int w = e.to();
                if (!marked[w]) {
                    dfs(G, w);
                }
            }
            postorder.enqueue(v);
            post[v] = postCounter++;
        }

        public int pre(int v) {
            validateVertex(v);
            return pre[v];
        }

        public int post(int v) {
            validateVertex(v);
            return post[v];
        }

        public Iterable<Integer> post() {
            return postorder;
        }

        public Iterable<Integer> pre() {
            return preorder;
        }

        public Iterable<Integer> reversePost() {
            Stack<Integer> reverse = new Stack<Integer>();
            for (int v : postorder)
                reverse.push(v);
            return reverse;
        }

        private boolean check() {

            // check that post(v) is consistent with post()
            int r = 0;
            for (int v : post()) {
                if (post(v) != r) {
                    StdOut.println("post(v) and post() inconsistent");
                    return false;
                }
                r++;
            }

            // check that pre(v) is consistent with pre()
            r = 0;
            for (int v : pre()) {
                if (pre(v) != r) {
                    StdOut.println("pre(v) and pre() inconsistent");
                    return false;
                }
                r++;
            }

            return true;
        }

        private void validateVertex(int v) {
            int V = marked.length;
            if (v < 0 || v >= V)
                throw new IllegalArgumentException("vertex " + v + " is not between 0 and " + (V - 1));
        }

    }

    static class DirectedCycle {
        private boolean[] marked;
        private int[] edgeTo;
        private boolean[] onStack;
        private Stack<Integer> cycle;

        public DirectedCycle(Digraph G) {
            marked = new boolean[G.V()];
            onStack = new boolean[G.V()];
            edgeTo = new int[G.V()];
            for (int v = 0; v < G.V(); v++)
                if (!marked[v] && cycle == null) dfs(G, v);
        }

        private void dfs(Digraph G, int v) {
            onStack[v] = true;
            marked[v] = true;
            for (int w : G.adj(v)) {

                // short circuit if directed cycle found
                if (cycle != null) return;

                    // found new vertex, so recur
                else if (!marked[w]) {
                    edgeTo[w] = v;
                    dfs(G, w);
                }

                // trace back directed cycle
                else if (onStack[w]) {
                    cycle = new Stack<Integer>();
                    for (int x = v; x != w; x = edgeTo[x]) {
                        cycle.push(x);
                    }
                    cycle.push(w);
                    cycle.push(v);
                    assert check();
                }
            }
            onStack[v] = false;
        }

        public boolean hasCycle() {
            return cycle != null;
        }

        public Iterable<Integer> cycle() {
            return cycle;
        }

        private boolean check() {

            if (hasCycle()) {
                // verify cycle
                int first = -1, last = -1;
                for (int v : cycle()) {
                    if (first == -1) first = v;
                    last = v;
                }
                if (first != last) {
                    System.err.printf("cycle begins with %d and ends with %d\n", first, last);
                    return false;
                }
            }


            return true;
        }

    }

    static final class In {
        private static final String CHARSET_NAME = "UTF-8";
        private static final Locale LOCALE = Locale.US;
        private Scanner scanner;

        public In() {
            scanner = new Scanner(new BufferedInputStream(System.in), CHARSET_NAME);
            scanner.useLocale(LOCALE);
        }

        public In(Socket socket) {
            if (socket == null) throw new IllegalArgumentException("socket argument is null");
            try {
                InputStream is = socket.getInputStream();
                scanner = new Scanner(new BufferedInputStream(is), CHARSET_NAME);
                scanner.useLocale(LOCALE);
            } catch (IOException ioe) {
                throw new IllegalArgumentException("Could not open " + socket, ioe);
            }
        }

        public In(URL url) {
            if (url == null) throw new IllegalArgumentException("url argument is null");
            try {
                URLConnection site = url.openConnection();
                InputStream is = site.getInputStream();
                scanner = new Scanner(new BufferedInputStream(is), CHARSET_NAME);
                scanner.useLocale(LOCALE);
            } catch (IOException ioe) {
                throw new IllegalArgumentException("Could not open " + url, ioe);
            }
        }

        public In(File file) {
            if (file == null) throw new IllegalArgumentException("file argument is null");
            try {
                // for consistency with StdIn, wrap with BufferedInputStream instead of use
                // file as argument to Scanner
                FileInputStream fis = new FileInputStream(file);
                scanner = new Scanner(new BufferedInputStream(fis), CHARSET_NAME);
                scanner.useLocale(LOCALE);
            } catch (IOException ioe) {
                throw new IllegalArgumentException("Could not open " + file, ioe);
            }
        }

        public In(String name) {
            if (name == null) throw new IllegalArgumentException("argument is null");
            try {
                // first try to read file from local file system
                File file = new File(name);
                if (file.exists()) {
                    // for consistency with StdIn, wrap with BufferedInputStream instead of use
                    // file as argument to Scanner
                    FileInputStream fis = new FileInputStream(file);
                    scanner = new Scanner(new BufferedInputStream(fis), CHARSET_NAME);
                    scanner.useLocale(LOCALE);
                    return;
                }

                // next try for files included in jar
                URL url = getClass().getResource(name);

                // or URL from web
                if (url == null) {
                    url = new URL(name);
                }

                URLConnection site = url.openConnection();

                // in order to set User-Agent, replace above line with these two
                // HttpURLConnection site = (HttpURLConnection) url.openConnection();
                // site.addRequestProperty("User-Agent", "Mozilla/4.76");

                InputStream is = site.getInputStream();
                scanner = new Scanner(new BufferedInputStream(is), CHARSET_NAME);
                scanner.useLocale(LOCALE);
            } catch (IOException ioe) {
                throw new IllegalArgumentException("Could not open " + name, ioe);
            }
        }

        public In(Scanner scanner) {
            if (scanner == null) throw new IllegalArgumentException("scanner argument is null");
            this.scanner = scanner;
        }

        public int readInt() {
            try {
                return scanner.nextInt();
            } catch (InputMismatchException e) {
                String token = scanner.next();
                throw new InputMismatchException("attempts to read an 'int' value from input stream, but the next token is \"" + token + "\"");
            } catch (NoSuchElementException e) {
                throw new NoSuchElementException("attemps to read an 'int' value from input stream, but there are no more tokens available");
            }
        }

        public double readDouble() {
            try {
                return scanner.nextDouble();
            } catch (InputMismatchException e) {
                String token = scanner.next();
                throw new InputMismatchException("attempts to read a 'double' value from input stream, but the next token is \"" + token + "\"");
            } catch (NoSuchElementException e) {
                throw new NoSuchElementException("attemps to read a 'double' value from input stream, but there are no more tokens available");
            }
        }

    }

    static class Queue<Item> implements Iterable<Item> {
        private Queue.Node<Item> first;
        private Queue.Node<Item> last;
        private int n;

        public Queue() {
            first = null;
            last = null;
            n = 0;
        }

        public boolean isEmpty() {
            return first == null;
        }

        public void enqueue(Item item) {
            Queue.Node<Item> oldlast = last;
            last = new Queue.Node<Item>();
            last.item = item;
            last.next = null;
            if (isEmpty()) first = last;
            else oldlast.next = last;
            n++;
        }

        public String toString() {
            StringBuilder s = new StringBuilder();
            for (Item item : this) {
                s.append(item);
                s.append(' ');
            }
            return s.toString();
        }

        public Iterator<Item> iterator() {
            return new ListIterator<Item>(first);
        }

        private static class Node<Item> {
            private Item item;
            private Queue.Node<Item> next;

        }

        private class ListIterator<Item> implements Iterator<Item> {
            private Queue.Node<Item> current;

            public ListIterator(Queue.Node<Item> first) {
                current = first;
            }

            public boolean hasNext() {
                return current != null;
            }

            public void remove() {
                throw new UnsupportedOperationException();
            }

            public Item next() {
                if (!hasNext()) throw new NoSuchElementException();
                Item item = current.item;
                current = current.next;
                return item;
            }

        }

    }

    static class Stack<Item> implements Iterable<Item> {
        private Stack.Node<Item> first;
        private int n;

        public Stack() {
            first = null;
            n = 0;
        }

        public void push(Item item) {
            Stack.Node<Item> oldfirst = first;
            first = new Stack.Node<Item>();
            first.item = item;
            first.next = oldfirst;
            n++;
        }

        public String toString() {
            StringBuilder s = new StringBuilder();
            for (Item item : this) {
                s.append(item);
                s.append(' ');
            }
            return s.toString();
        }

        public Iterator<Item> iterator() {
            return new ListIterator<Item>(first);
        }

        private static class Node<Item> {
            private Item item;
            private Stack.Node<Item> next;

        }

        private class ListIterator<Item> implements Iterator<Item> {
            private Stack.Node<Item> current;

            public ListIterator(Stack.Node<Item> first) {
                current = first;
            }

            public boolean hasNext() {
                return current != null;
            }

            public void remove() {
                throw new UnsupportedOperationException();
            }

            public Item next() {
                if (!hasNext()) throw new NoSuchElementException();
                Item item = current.item;
                current = current.next;
                return item;
            }

        }

    }

    static final class StdRandom {
        private static Random random;
        private static long seed;

        // static initializer
        static {
            // this is how the seed was set in Java 1.4
            seed = System.currentTimeMillis();
            random = new Random(seed);
        }

        private StdRandom() {
        }

        public static int uniform(int n) {
            if (n <= 0) throw new IllegalArgumentException("argument must be positive");
            return random.nextInt(n);
        }

    }

    static class Topological {
        private Iterable<Integer> order;
        private int[] rank;

        public Topological(Digraph G) {
            DirectedCycle finder = new DirectedCycle(G);
            if (!finder.hasCycle()) {
                DepthFirstOrder dfs = new DepthFirstOrder(G);
                order = dfs.reversePost();
                rank = new int[G.V()];
                int i = 0;
                for (int v : order)
                    rank[v] = i++;
            }
        }

        public Topological(EdgeWeightedDigraph G) {
            EdgeWeightedDirectedCycle finder = new EdgeWeightedDirectedCycle(G);
            if (!finder.hasCycle()) {
                DepthFirstOrder dfs = new DepthFirstOrder(G);
                order = dfs.reversePost();
            }
        }

        public Iterable<Integer> order() {
            return order;
        }

        public boolean hasOrder() {
            return order != null;
        }

    }

    static class Bag<Item> implements Iterable<Item> {
        private Bag.Node<Item> first;
        private int n;

        public Bag() {
            first = null;
            n = 0;
        }

        public void add(Item item) {
            Bag.Node<Item> oldfirst = first;
            first = new Bag.Node<Item>();
            first.item = item;
            first.next = oldfirst;
            n++;
        }

        public Iterator<Item> iterator() {
            return new ListIterator<Item>(first);
        }

        private static class Node<Item> {
            private Item item;
            private Bag.Node<Item> next;

        }

        private class ListIterator<Item> implements Iterator<Item> {
            private Bag.Node<Item> current;

            public ListIterator(Bag.Node<Item> first) {
                current = first;
            }

            public boolean hasNext() {
                return current != null;
            }

            public void remove() {
                throw new UnsupportedOperationException();
            }

            public Item next() {
                if (!hasNext()) throw new NoSuchElementException();
                Item item = current.item;
                current = current.next;
                return item;
            }

        }

    }

    static class EdgeWeightedDirectedCycle {
        private boolean[] marked;
        private DirectedEdge[] edgeTo;
        private boolean[] onStack;
        private Stack<DirectedEdge> cycle;

        public EdgeWeightedDirectedCycle(EdgeWeightedDigraph G) {
            marked = new boolean[G.V()];
            onStack = new boolean[G.V()];
            edgeTo = new DirectedEdge[G.V()];
            for (int v = 0; v < G.V(); v++)
                if (!marked[v]) dfs(G, v);

            // check that digraph has a cycle
            assert check();
        }

        private void dfs(EdgeWeightedDigraph G, int v) {
            onStack[v] = true;
            marked[v] = true;
            for (DirectedEdge e : G.adj(v)) {
                int w = e.to();

                // short circuit if directed cycle found
                if (cycle != null) return;

                    // found new vertex, so recur
                else if (!marked[w]) {
                    edgeTo[w] = e;
                    dfs(G, w);
                }

                // trace back directed cycle
                else if (onStack[w]) {
                    cycle = new Stack<DirectedEdge>();

                    DirectedEdge f = e;
                    while (f.from() != w) {
                        cycle.push(f);
                        f = edgeTo[f.from()];
                    }
                    cycle.push(f);

                    return;
                }
            }

            onStack[v] = false;
        }

        public boolean hasCycle() {
            return cycle != null;
        }

        public Iterable<DirectedEdge> cycle() {
            return cycle;
        }

        private boolean check() {

            // edge-weighted digraph is cyclic
            if (hasCycle()) {
                // verify cycle
                DirectedEdge first = null, last = null;
                for (DirectedEdge e : cycle()) {
                    if (first == null) first = e;
                    if (last != null) {
                        if (last.to() != e.from()) {
                            System.err.printf("cycle edges %s and %s not incident\n", last, e);
                            return false;
                        }
                    }
                    last = e;
                }

                if (last.to() != first.from()) {
                    System.err.printf("cycle edges %s and %s not incident\n", last, first);
                    return false;
                }
            }


            return true;
        }

    }

    static class DirectedEdge {
        private final int v;
        private final int w;
        private final double weight;

        public DirectedEdge(int v, int w, double weight) {
            if (v < 0) throw new IllegalArgumentException("Vertex names must be nonnegative integers");
            if (w < 0) throw new IllegalArgumentException("Vertex names must be nonnegative integers");
            if (Double.isNaN(weight)) throw new IllegalArgumentException("Weight is NaN");
            this.v = v;
            this.w = w;
            this.weight = weight;
        }

        public int from() {
            return v;
        }

        public int to() {
            return w;
        }

        public String toString() {
            return v + "->" + w + " " + String.format("%5.2f", weight);
        }

    }
}