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

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

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

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

c.x = a
d.q = e
n.w = h
n.s = j
h.w = a
h.s = j
e.q = d
j.w = a
j.s = a
i.x = n
a.w = j
a.s = j
f.x = j
assert j.s.s.s.s.s.w.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

c.x = a
d.q = e
n.w = h
n.s = j
h.w = a
h.s = j
e.q = d
j.w = a
j.s = a
i.x = n
a.w = j
a.s = j
f.x = j
assert j.s.s.s.s.s.w.s.w.txt == "j"