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

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

m = A("m")
i = B("i")
c = A("c")
k = A("k")
j = B("j")
g = B("g")
e = B("e")

m.o = c
m.x = k
i.z = g
i.q = j
c.o = m
c.x = m
k.o = c
k.x = c
j.z = e
j.q = e
g.z = j
g.q = j
e.z = j
e.q = j
assert j.z.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.x: A = None
        self.txt = txt

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

m = A("m")
i = B("i")
c = A("c")
k = A("k")
j = B("j")
g = B("g")
e = B("e")

m.o = c
m.x = k
i.z = g
i.q = j
c.o = m
c.x = m
k.o = c
k.x = c
j.z = e
j.q = e
g.z = j
g.q = j
e.z = j
e.q = j
assert j.z.z.q.txt == "e"