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

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

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

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

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

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

h.y = j
j.q = k
k.y = j
f.q = l
c.y = i
i.q = k
m.y = j
l.y = f
assert h.y.q.y.q.y.q.txt == "k"