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

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

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

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

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

i = A("i")
m = B("m")
a = C("a")
b = D("b")
j = E("j")

i.w = b
i.p = b
i.t = a
m.w = i
m.x = j
m.o = j
m.t = j
m.s = b
a.w = j
a.r = j
a.q = j
b.p = a
j.s = m
assert a.w.s.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.p: D = None
        self.t: C = None
        self.txt = txt

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

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

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

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

i = A("i")
m = B("m")
a = C("a")
b = D("b")
j = E("j")

i.w = b
i.p = b
i.t = a
m.w = i
m.x = j
m.o = j
m.t = j
m.s = b
a.w = j
a.r = j
a.q = j
b.p = a
j.s = m
assert a.w.s.x.s.txt == "m"