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

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

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

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

k = A("k")
j = B("j")
d = C("d")
b = D("b")
c = D("c")

k.r = j
k.o = c
j.q = b
j.s = d
d.z = j
d.x = k
b.u = k
b.t = k
b.y = d
b.r = j
c.u = k
c.t = k
c.y = d
c.r = j
assert b.t.r.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.o: D = None
        self.txt = txt

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

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

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

k = A("k")
j = B("j")
d = C("d")
b = D("b")
c = D("c")

k.r = j
k.o = c
j.q = b
j.s = d
d.z = j
d.x = k
b.u = k
b.t = k
b.y = d
b.r = j
c.u = k
c.t = k
c.y = d
c.r = j
assert b.t.r.s.x.txt == "k"