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

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: A = None
        self.u: C = None
        self.q: A = None
        self.txt = txt

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

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

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

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

i.y = m
e.z = b
e.t = i
e.q = i
e.u = h
m.t = c
c.q = n
c.v = g
n.x = m
b.q = n
b.v = g
h.t = b
g.z = c
g.t = i
g.q = i
g.u = h
assert b.q.x.t.q.x.t.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: A = None
        self.u: C = None
        self.q: A = None
        self.txt = txt

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

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

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

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

i.y = m
e.z = b
e.t = i
e.q = i
e.u = h
m.t = c
c.q = n
c.v = g
n.x = m
b.q = n
b.v = g
h.t = b
g.z = c
g.t = i
g.q = i
g.u = h
assert b.q.x.t.q.x.t.q.x.txt == "m"