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

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

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

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

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

f = A("f")
l = B("l")
d = C("d")
h = D("h")
n = E("n")
j = D("j")

f.s = j
f.t = l
l.r = j
d.u = l
d.t = j
d.s = n
h.r = l
n.s = d
n.p = d
n.u = l
n.y = l
j.r = l
assert f.s.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.t: B = None
        self.txt = txt

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

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

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

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

f = A("f")
l = B("l")
d = C("d")
h = D("h")
n = E("n")
j = D("j")

f.s = j
f.t = l
l.r = j
d.u = l
d.t = j
d.s = n
h.r = l
n.s = d
n.p = d
n.u = l
n.y = l
j.r = l
assert f.s.r.r.r.r.r.txt == "l"