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

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

a = A("a")
j = B("j")
n = B("n")
i = A("i")
k = A("k")
l = B("l")

a.q = l
a.o = l
j.o = i
j.y = a
n.o = a
n.y = k
i.q = l
i.o = l
k.q = n
k.o = l
l.o = a
l.y = i
assert i.q.o.q.o.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: B = None
        self.txt = txt

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

a = A("a")
j = B("j")
n = B("n")
i = A("i")
k = A("k")
l = B("l")

a.q = l
a.o = l
j.o = i
j.y = a
n.o = a
n.y = k
i.q = l
i.o = l
k.q = n
k.o = l
l.o = a
l.y = i
assert i.q.o.q.o.o.y.txt == "i"