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

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

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

l = A("l")
i = B("i")
h = C("h")
d = B("d")
j = B("j")
b = A("b")
e = B("e")
n = B("n")
f = C("f")
a = C("a")

l.u = f
i.y = j
h.q = a
h.u = l
h.w = j
d.y = i
j.y = e
b.u = a
e.y = n
n.y = e
f.q = a
f.u = l
f.w = i
a.q = f
a.u = l
a.w = d
assert i.y.y.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

l = A("l")
i = B("i")
h = C("h")
d = B("d")
j = B("j")
b = A("b")
e = B("e")
n = B("n")
f = C("f")
a = C("a")

l.u = f
i.y = j
h.q = a
h.u = l
h.w = j
d.y = i
j.y = e
b.u = a
e.y = n
n.y = e
f.q = a
f.u = l
f.w = i
a.q = f
a.u = l
a.w = d
assert i.y.y.y.y.y.y.y.y.y.txt == "n"