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

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

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

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

k = A("k")
j = B("j")
d = C("d")
l = D("l")

k.p = d
k.r = d
k.t = d
k.s = j
j.z = l
j.o = l
j.q = k
d.w = k
l.x = k
l.o = k
assert k.t.w.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: C = None
        self.s: B = None
        self.t: C = None
        self.txt = txt

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

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

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

k = A("k")
j = B("j")
d = C("d")
l = D("l")

k.p = d
k.r = d
k.t = d
k.s = j
j.z = l
j.o = l
j.q = k
d.w = k
l.x = k
l.o = k
assert k.t.w.s.q.txt == "k"