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

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

k = A("k")
g = B("g")
l = A("l")
f = A("f")
c = B("c")
j = A("j")
n = B("n")
b = B("b")
i = A("i")

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

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

k = A("k")
g = B("g")
l = A("l")
f = A("f")
c = B("c")
j = A("j")
n = B("n")
b = B("b")
i = A("i")

k.y = l
g.q = b
l.y = f
f.y = j
c.q = b
j.y = l
n.q = b
b.q = c
i.y = l
assert b.q.q.q.txt == "c"