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

c = A("c")
l = B("l")
j = B("j")
e = A("e")
f = B("f")
g = A("g")
a = B("a")
i = A("i")
m = A("m")

c.o = e
l.q = g
j.q = g
e.o = m
f.q = i
g.o = c
a.q = m
i.o = e
m.o = g
assert a.q.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

c = A("c")
l = B("l")
j = B("j")
e = A("e")
f = B("f")
g = A("g")
a = B("a")
i = A("i")
m = A("m")

c.o = e
l.q = g
j.q = g
e.o = m
f.q = i
g.o = c
a.q = m
i.o = e
m.o = g
assert a.q.o.o.txt == "c"