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

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

l = A("l")
b = B("b")
a = B("a")
j = A("j")
f = A("f")
h = B("h")

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

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

l = A("l")
b = B("b")
a = B("a")
j = A("j")
f = A("f")
h = B("h")

l.v = a
l.y = h
b.x = l
a.x = l
j.v = b
j.y = a
f.v = a
f.y = b
h.x = l
assert f.v.x.y.txt == "h"