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

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

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

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

m = A("m")
j = B("j")
g = C("g")
k = D("k")
a = C("a")

m.w = k
m.o = k
m.x = g
m.y = j
j.q = m
g.q = j
g.r = j
k.s = j
k.w = j
k.z = g
a.q = j
a.r = j
assert k.w.q.x.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.o: D = None
        self.x: C = None
        self.y: B = None
        self.txt = txt

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

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

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

m = A("m")
j = B("j")
g = C("g")
k = D("k")
a = C("a")

m.w = k
m.o = k
m.x = g
m.y = j
j.q = m
g.q = j
g.r = j
k.s = j
k.w = j
k.z = g
a.q = j
a.r = j
assert k.w.q.x.q.q.txt == "m"