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

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

b = A("b")
c = B("c")
e = B("e")
g = A("g")
j = B("j")
n = A("n")

b.o = c
c.q = g
c.o = j
e.q = b
e.o = j
g.o = c
j.q = b
j.o = e
n.o = j
assert c.q.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

b = A("b")
c = B("c")
e = B("e")
g = A("g")
j = B("j")
n = A("n")

b.o = c
c.q = g
c.o = j
e.q = b
e.o = j
g.o = c
j.q = b
j.o = e
n.o = j
assert c.q.o.o.txt == "j"