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

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

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

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

f = A("f")
j = B("j")
m = C("m")
e = D("e")

f.x = e
f.v = j
j.o = e
j.z = m
m.u = f
m.s = f
m.z = j
m.q = j
e.r = f
assert e.r.x.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.v: B = None
        self.txt = txt

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

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

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

f = A("f")
j = B("j")
m = C("m")
e = D("e")

f.x = e
f.v = j
j.o = e
j.z = m
m.u = f
m.s = f
m.z = j
m.q = j
e.r = f
assert e.r.x.r.v.txt == "j"