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

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

c = A("c")
h = B("h")
n = A("n")
j = A("j")
e = A("e")
k = A("k")

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

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

c = A("c")
h = B("h")
n = A("n")
j = A("j")
e = A("e")
k = A("k")

c.o = e
c.q = j
h.o = e
n.o = e
n.q = e
j.o = k
j.q = c
e.o = n
e.q = j
k.o = c
k.q = n
assert j.o.q.o.o.o.txt == "e"