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

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

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

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

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

n = A("n")
b = B("b")
g = C("g")
m = D("m")
e = E("e")

n.w = e
n.u = e
b.t = g
b.u = g
b.r = m
g.s = m
g.o = n
g.p = n
g.w = b
m.r = e
m.y = e
m.u = b
m.v = g
e.r = m
assert n.u.r.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.u: E = None
        self.txt = txt

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

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

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

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

n = A("n")
b = B("b")
g = C("g")
m = D("m")
e = E("e")

n.w = e
n.u = e
b.t = g
b.u = g
b.r = m
g.s = m
g.o = n
g.p = n
g.w = b
m.r = e
m.y = e
m.u = b
m.v = g
e.r = m
assert n.u.r.u.r.txt == "m"