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

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

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

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

f = A("f")
l = B("l")
h = C("h")
d = D("d")
a = C("a")
c = D("c")
k = D("k")

f.v = a
l.x = h
h.z = a
d.x = l
d.r = h
d.t = f
d.z = a
a.z = h
c.x = l
c.r = a
c.z = a
c.t = f
k.x = l
k.r = h
k.t = f
k.z = a
assert h.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

f = A("f")
l = B("l")
h = C("h")
d = D("d")
a = C("a")
c = D("c")
k = D("k")

f.v = a
l.x = h
h.z = a
d.x = l
d.r = h
d.t = f
d.z = a
a.z = h
c.x = l
c.r = a
c.z = a
c.t = f
k.x = l
k.r = h
k.t = f
k.z = a
assert h.z.z.z.z.z.txt == "a"