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

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.z: B = None
        self.w: D = None
        self.o: D = None
        self.q: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.p: B = None
        self.o: B = None
        self.u: A = None
        self.x: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.q: A = None
        self.y: C = None
        self.s: E = None
        self.p: E = None
        self.txt = txt

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

h.y = a
g.u = n
g.z = f
g.q = f
g.w = i
g.o = i
m.t = i
m.x = i
m.p = f
m.o = f
m.u = h
a.p = i
c.u = h
c.q = h
c.y = m
c.s = n
c.p = n
n.u = h
n.q = h
n.y = m
n.s = c
n.p = c
f.u = n
f.z = g
f.q = g
f.w = i
f.o = i
i.p = a
assert m.t.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.z: B = None
        self.w: D = None
        self.o: D = None
        self.q: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.p: B = None
        self.o: B = None
        self.u: A = None
        self.x: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.q: A = None
        self.y: C = None
        self.s: E = None
        self.p: E = None
        self.txt = txt

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

h.y = a
g.u = n
g.z = f
g.q = f
g.w = i
g.o = i
m.t = i
m.x = i
m.p = f
m.o = f
m.u = h
a.p = i
c.u = h
c.q = h
c.y = m
c.s = n
c.p = n
n.u = h
n.q = h
n.y = m
n.s = c
n.p = c
f.u = n
f.z = g
f.q = g
f.w = i
f.o = i
i.p = a
assert m.t.p.p.p.p.p.p.txt == "i"