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

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

i = A("i")
l = B("l")
h = A("h")
j = A("j")
g = A("g")
f = B("f")
n = A("n")

i.z = f
i.x = f
l.v = j
h.z = f
h.x = f
j.z = l
j.x = f
g.z = l
g.x = l
f.v = i
n.z = f
n.x = l
assert f.v.z.v.x.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: B = None
        self.txt = txt

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

i = A("i")
l = B("l")
h = A("h")
j = A("j")
g = A("g")
f = B("f")
n = A("n")

i.z = f
i.x = f
l.v = j
h.z = f
h.x = f
j.z = l
j.x = f
g.z = l
g.x = l
f.v = i
n.z = f
n.x = l
assert f.v.z.v.x.v.z.v.txt == "i"