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

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

i = A("i")
l = B("l")
c = A("c")
k = B("k")
g = B("g")
e = A("e")
h = B("h")
d = B("d")
f = B("f")

i.s = e
l.q = g
c.s = i
k.q = f
g.q = d
e.s = c
h.q = g
d.q = l
f.q = d
assert h.q.q.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

i = A("i")
l = B("l")
c = A("c")
k = B("k")
g = B("g")
e = A("e")
h = B("h")
d = B("d")
f = B("f")

i.s = e
l.q = g
c.s = i
k.q = f
g.q = d
e.s = c
h.q = g
d.q = l
f.q = d
assert h.q.q.q.q.q.q.q.q.txt == "d"