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

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

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

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

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

g = A("g")
c = B("c")
j = C("j")
a = D("a")
h = E("h")
m = E("m")
e = E("e")
d = E("d")
b = B("b")
f = A("f")

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

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

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

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

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

g = A("g")
c = B("c")
j = C("j")
a = D("a")
h = E("h")
m = E("m")
e = E("e")
d = E("d")
b = B("b")
f = A("f")

g.u = a
c.w = j
j.y = m
j.s = e
a.r = j
a.q = b
h.w = a
h.r = a
h.p = m
m.w = a
m.r = a
m.p = h
e.w = a
e.r = a
e.p = m
d.w = a
d.r = a
d.p = h
b.w = j
f.u = a
assert j.y.r.q.w.s.p.txt == "m"