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

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

j = A("j")
k = B("k")
a = A("a")

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

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

j = A("j")
k = B("k")
a = A("a")

j.v = a
j.q = a
k.o = a
a.v = j
a.q = j
assert j.v.q.v.txt == "a"