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

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

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

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

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

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

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

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

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

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

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

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

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