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

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

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

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

c = A("c")
g = B("g")
f = C("f")
m = D("m")
a = B("a")
i = B("i")
d = C("d")

c.z = i
g.z = c
f.v = d
f.x = d
f.t = i
m.v = c
m.w = g
a.z = c
i.z = c
d.v = f
d.x = f
d.t = g
assert a.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

c = A("c")
g = B("g")
f = C("f")
m = D("m")
a = B("a")
i = B("i")
d = C("d")

c.z = i
g.z = c
f.v = d
f.x = d
f.t = i
m.v = c
m.w = g
a.z = c
i.z = c
d.v = f
d.x = f
d.t = g
assert a.z.z.z.z.txt == "i"