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

class B:
    def __init__(self, txt: str):
        self.v: A = 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.t: A = None
        self.r: A = None
        self.txt = txt

b = A("b")
j = B("j")
i = C("i")
m = D("m")

b.q = i
b.p = i
b.u = j
b.o = j
j.v = b
i.w = b
m.t = b
m.r = b
assert m.r.p.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: B = None
        self.p: C = None
        self.o: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = 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.t: A = None
        self.r: A = None
        self.txt = txt

b = A("b")
j = B("j")
i = C("i")
m = D("m")

b.q = i
b.p = i
b.u = j
b.o = j
j.v = b
i.w = b
m.t = b
m.r = b
assert m.r.p.w.u.txt == "j"