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

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

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

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

b = A("b")
m = B("m")
h = C("h")
c = D("c")

b.t = c
b.x = c
b.w = c
b.z = m
m.o = c
m.w = c
h.p = b
h.q = c
c.r = m
c.o = b
c.x = b
assert h.q.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.z: B = None
        self.x: D = None
        self.w: D = None
        self.txt = txt

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

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

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

b = A("b")
m = B("m")
h = C("h")
c = D("c")

b.t = c
b.x = c
b.w = c
b.z = m
m.o = c
m.w = c
h.p = b
h.q = c
c.r = m
c.o = b
c.x = b
assert h.q.r.o.txt == "c"