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

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

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

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

b = A("b")
k = B("k")
m = C("m")
l = D("l")
f = B("f")
c = C("c")
g = A("g")
d = A("d")
a = D("a")

b.t = k
k.z = a
k.x = f
k.s = l
k.u = c
m.z = k
l.w = b
f.z = l
f.s = l
f.x = k
f.u = c
c.z = f
g.t = f
d.t = f
a.w = b
assert a.w.t.z.w.t.z.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

b = A("b")
k = B("k")
m = C("m")
l = D("l")
f = B("f")
c = C("c")
g = A("g")
d = A("d")
a = D("a")

b.t = k
k.z = a
k.x = f
k.s = l
k.u = c
m.z = k
l.w = b
f.z = l
f.s = l
f.x = k
f.u = c
c.z = f
g.t = f
d.t = f
a.w = b
assert a.w.t.z.w.t.z.w.t.txt == "k"