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

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

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

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

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

k.x = i
i.r = k
i.v = b
i.t = j
c.o = j
j.z = b
j.q = i
b.o = j
assert b.o.q.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

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

k.x = i
i.r = k
i.v = b
i.t = j
c.o = j
j.z = b
j.q = i
b.o = j
assert b.o.q.v.o.txt == "j"