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

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

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

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

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

i.r = m
i.t = h
h.o = b
h.v = b
h.x = m
m.o = i
m.z = h
m.s = h
b.p = m
assert i.t.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.t: B = None
        self.txt = txt

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

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

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

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

i.r = m
i.t = h
h.o = b
h.v = b
h.x = m
m.o = i
m.z = h
m.s = h
b.p = m
assert i.t.x.o.txt == "i"