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

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

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

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

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

l = A("l")
m = B("m")
a = C("a")
e = D("e")
g = E("g")
h = C("h")
f = A("f")

l.r = e
m.w = e
m.p = e
m.r = e
m.u = h
m.y = a
a.s = g
a.r = e
a.u = f
e.s = m
e.y = f
e.o = g
g.u = l
h.s = g
h.r = e
h.u = f
f.r = e
assert l.r.y.r.s.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

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

l = A("l")
m = B("m")
a = C("a")
e = D("e")
g = E("g")
h = C("h")
f = A("f")

l.r = e
m.w = e
m.p = e
m.r = e
m.u = h
m.y = a
a.s = g
a.r = e
a.u = f
e.s = m
e.y = f
e.o = g
g.u = l
h.s = g
h.r = e
h.u = f
f.r = e
assert l.r.y.r.s.u.r.txt == "e"