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

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

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

class D:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: E = None
        self.x: C = None
        self.q: B = None
        self.p: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

i = A("i")
c = B("c")
j = C("j")
g = D("g")
n = E("n")

i.w = j
i.r = c
c.x = i
c.z = n
j.r = c
g.u = c
g.q = c
g.p = c
g.w = n
g.x = j
n.u = g
assert n.u.w.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.r: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: E = None
        self.x: C = None
        self.q: B = None
        self.p: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

i = A("i")
c = B("c")
j = C("j")
g = D("g")
n = E("n")

i.w = j
i.r = c
c.x = i
c.z = n
j.r = c
g.u = c
g.q = c
g.p = c
g.w = n
g.x = j
n.u = g
assert n.u.w.u.w.txt == "n"