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

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

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

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

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

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

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

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

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

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

j.v = h
j.s = i
h.y = m
h.p = m
h.t = i
m.w = h
m.z = h
m.o = j
m.r = j
i.y = m
i.z = j
i.q = j
i.x = h
assert i.x.t.x.t.txt == "i"