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

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

l = A("l")
h = B("h")
k = A("k")
c = B("c")
f = A("f")
g = B("g")
b = A("b")

l.v = h
l.o = f
h.x = c
h.y = f
k.v = c
k.o = b
c.x = g
c.y = b
f.v = c
f.o = l
g.x = h
g.y = b
b.v = h
b.o = l
assert l.v.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: A = None
        self.txt = txt

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

l = A("l")
h = B("h")
k = A("k")
c = B("c")
f = A("f")
g = B("g")
b = A("b")

l.v = h
l.o = f
h.x = c
h.y = f
k.v = c
k.o = b
c.x = g
c.y = b
f.v = c
f.o = l
g.x = h
g.y = b
b.v = h
b.o = l
assert l.v.x.y.txt == "b"