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

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

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

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

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

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

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

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

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

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

m.x = j
m.o = g
m.v = g
g.r = j
g.x = m
j.t = m
j.s = m
j.y = m
j.w = g
h.s = g
assert g.r.s.v.x.txt == "m"