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

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

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

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

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

a.u = k
a.o = k
a.p = i
i.s = l
k.s = m
k.t = m
k.q = i
l.p = m
m.u = k
m.o = k
m.p = i
assert a.u.q.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.p: B = None
        self.o: C = None
        self.txt = txt

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

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

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

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

a.u = k
a.o = k
a.p = i
i.s = l
k.s = m
k.t = m
k.q = i
l.p = m
m.u = k
m.o = k
m.p = i
assert a.u.q.s.p.txt == "m"