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

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

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

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

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

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

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

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

i.q = b
i.s = c
i.y = l
h.y = k
h.s = c
k.w = l
b.q = l
b.s = g
b.y = i
g.y = a
g.s = j
j.y = k
j.s = h
a.w = b
c.y = a
c.s = j
l.q = b
l.s = c
l.y = i
n.q = i
n.s = c
n.y = b
assert a.w.s.y.w.y.txt == "i"