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

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

n = A("n")
g = B("g")
b = B("b")
c = B("c")
l = A("l")
a = A("a")
i = A("i")

n.o = l
g.q = a
b.q = n
c.q = l
l.o = i
a.o = l
i.o = n
assert l.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

n = A("n")
g = B("g")
b = B("b")
c = B("c")
l = A("l")
a = A("a")
i = A("i")

n.o = l
g.q = a
b.q = n
c.q = l
l.o = i
a.o = l
i.o = n
assert l.o.o.o.o.o.txt == "n"