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

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

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

i = A("i")
h = B("h")
b = C("b")
d = B("d")
c = A("c")
k = B("k")
a = B("a")
n = A("n")
g = C("g")

i.y = n
h.q = b
h.y = g
b.s = c
b.t = g
d.q = b
d.y = b
c.y = i
k.q = g
k.y = g
a.q = b
a.y = g
n.y = c
g.s = i
g.t = b
assert a.y.t.s.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

i = A("i")
h = B("h")
b = C("b")
d = B("d")
c = A("c")
k = B("k")
a = B("a")
n = A("n")
g = C("g")

i.y = n
h.q = b
h.y = g
b.s = c
b.t = g
d.q = b
d.y = b
c.y = i
k.q = g
k.y = g
a.q = b
a.y = g
n.y = c
g.s = i
g.t = b
assert a.y.t.s.y.y.y.y.txt == "i"