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

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

g = A("g")
a = B("a")
k = B("k")
c = B("c")
h = A("h")

g.v = h
g.o = h
a.x = g
k.x = h
c.x = h
h.v = g
h.o = g
assert k.x.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.o: A = None
        self.txt = txt

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

g = A("g")
a = B("a")
k = B("k")
c = B("c")
h = A("h")

g.v = h
g.o = h
a.x = g
k.x = h
c.x = h
h.v = g
h.o = g
assert k.x.o.v.txt == "h"