class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

i.w = j
b.x = m
b.o = j
j.p = b
m.v = b
m.q = j
assert i.w.p.x.v.txt == "b"