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

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

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

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

k = A("k")
i = B("i")
f = C("f")
m = D("m")
b = B("b")
l = A("l")

k.t = b
k.q = m
k.r = m
k.p = i
i.r = k
i.u = m
f.q = m
m.r = k
m.z = k
m.u = l
b.r = l
b.u = m
l.t = b
l.q = m
l.r = m
l.p = i
assert f.q.r.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.q: D = None
        self.r: D = None
        self.p: B = None
        self.txt = txt

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

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

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

k = A("k")
i = B("i")
f = C("f")
m = D("m")
b = B("b")
l = A("l")

k.t = b
k.q = m
k.r = m
k.p = i
i.r = k
i.u = m
f.q = m
m.r = k
m.z = k
m.u = l
b.r = l
b.u = m
l.t = b
l.q = m
l.r = m
l.p = i
assert f.q.r.p.u.txt == "m"