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

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

h = A("h")
j = B("j")
m = B("m")
c = B("c")
f = A("f")
g = B("g")
d = B("d")
i = A("i")
l = B("l")

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

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

h = A("h")
j = B("j")
m = B("m")
c = B("c")
f = A("f")
g = B("g")
d = B("d")
i = A("i")
l = B("l")

h.q = i
j.s = d
m.s = l
c.s = g
f.q = i
g.s = c
d.s = m
i.q = h
l.s = m
assert h.q.q.q.q.q.txt == "i"