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

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

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

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

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

k.w = j
i.o = g
i.w = k
i.z = m
i.x = m
j.s = k
j.p = k
j.u = m
g.z = k
g.q = k
g.w = k
g.p = m
m.o = g
m.w = k
m.z = i
m.x = i
assert g.p.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

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

k.w = j
i.o = g
i.w = k
i.z = m
i.x = m
j.s = k
j.p = k
j.u = m
g.z = k
g.q = k
g.w = k
g.p = m
m.o = g
m.w = k
m.z = i
m.x = i
assert g.p.w.w.txt == "j"