class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: C = None
        self.q: D = None
        self.x: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: D = None
        self.s: B = None
        self.v: E = None
        self.txt = txt

a = A("a")
h = B("h")
g = C("g")
e = D("e")
f = E("f")
d = A("d")
i = A("i")
n = E("n")
c = E("c")
b = B("b")

a.q = d
h.s = g
h.q = e
h.x = f
g.q = e
e.o = n
f.t = e
f.s = b
f.v = n
d.q = i
i.q = d
n.t = e
n.s = h
n.v = c
c.t = e
c.s = h
c.v = n
b.s = g
b.q = e
b.x = c
assert f.t.o.t.o.s.s.q.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: C = None
        self.q: D = None
        self.x: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: D = None
        self.s: B = None
        self.v: E = None
        self.txt = txt

a = A("a")
h = B("h")
g = C("g")
e = D("e")
f = E("f")
d = A("d")
i = A("i")
n = E("n")
c = E("c")
b = B("b")

a.q = d
h.s = g
h.q = e
h.x = f
g.q = e
e.o = n
f.t = e
f.s = b
f.v = n
d.q = i
i.q = d
n.t = e
n.s = h
n.v = c
c.t = e
c.s = h
c.v = n
b.s = g
b.q = e
b.x = c
assert f.t.o.t.o.s.s.q.o.s.txt == "h"