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

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

i = A("i")
n = B("n")
g = C("g")
e = D("e")
a = D("a")
h = B("h")
f = B("f")
k = C("k")

i.x = e
n.s = f
g.r = e
g.u = k
e.z = a
a.z = e
h.s = n
f.s = h
k.r = a
k.u = g
assert a.z.z.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

i = A("i")
n = B("n")
g = C("g")
e = D("e")
a = D("a")
h = B("h")
f = B("f")
k = C("k")

i.x = e
n.s = f
g.r = e
g.u = k
e.z = a
a.z = e
h.s = n
f.s = h
k.r = a
k.u = g
assert a.z.z.z.z.z.z.z.z.txt == "a"