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

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

h = A("h")
m = B("m")
e = A("e")
j = B("j")
i = A("i")
f = A("f")

h.y = m
m.q = j
e.y = m
j.q = m
i.y = j
f.y = j
assert j.q.q.q.q.q.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: B = None
        self.txt = txt

h = A("h")
m = B("m")
e = A("e")
j = B("j")
i = A("i")
f = A("f")

h.y = m
m.q = j
e.y = m
j.q = m
i.y = j
f.y = j
assert j.q.q.q.q.q.q.txt == "j"