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

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

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

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

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

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

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

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

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

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

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

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

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