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

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

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

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

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

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

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

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

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

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

d.u = k
g.x = f
j.t = a
f.z = l
f.p = m
f.r = k
f.s = g
m.u = l
l.x = f
k.x = f
a.t = j
assert a.t.t.t.t.txt == "a"