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

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

class C:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.v: D = None
        self.p: A = None
        self.r: C = None
        self.txt = txt

m = A("m")
e = B("e")
j = C("j")
f = D("f")
g = E("g")

m.u = g
e.w = m
e.y = m
e.p = j
j.t = g
f.q = g
f.z = g
f.w = m
f.x = e
f.v = e
g.y = f
g.v = f
g.p = m
g.r = j
assert m.u.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.v: D = None
        self.p: A = None
        self.r: C = None
        self.txt = txt

m = A("m")
e = B("e")
j = C("j")
f = D("f")
g = E("g")

m.u = g
e.w = m
e.y = m
e.p = j
j.t = g
f.q = g
f.z = g
f.w = m
f.x = e
f.v = e
g.y = f
g.v = f
g.p = m
g.r = j
assert m.u.p.u.txt == "g"