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

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

g = A("g")
k = B("k")
j = A("j")
n = B("n")

g.x = k
g.o = j
k.v = g
k.q = j
j.x = n
j.o = g
n.v = g
n.q = g
assert j.x.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.o: A = None
        self.txt = txt

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

g = A("g")
k = B("k")
j = A("j")
n = B("n")

g.x = k
g.o = j
k.v = g
k.q = j
j.x = n
j.o = g
n.v = g
n.q = g
assert j.x.q.x.txt == "k"