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

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

l = A("l")
c = B("c")
e = A("e")
m = B("m")
j = A("j")
n = B("n")
f = A("f")
g = A("g")
h = B("h")

l.y = g
c.y = h
e.y = j
m.y = n
j.y = l
n.y = h
f.y = e
g.y = l
h.y = m
assert c.y.y.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

l = A("l")
c = B("c")
e = A("e")
m = B("m")
j = A("j")
n = B("n")
f = A("f")
g = A("g")
h = B("h")

l.y = g
c.y = h
e.y = j
m.y = n
j.y = l
n.y = h
f.y = e
g.y = l
h.y = m
assert c.y.y.y.y.y.y.y.y.y.txt == "n"