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

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

b = A("b")
i = B("i")
c = B("c")
h = A("h")
a = B("a")
g = A("g")
j = B("j")
k = A("k")

b.x = j
b.z = j
i.x = c
i.v = h
c.x = j
c.v = b
h.x = c
h.z = a
a.x = j
a.v = b
g.x = c
g.z = i
j.x = a
j.v = b
k.x = i
k.z = i
assert a.v.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: B = None
        self.txt = txt

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

b = A("b")
i = B("i")
c = B("c")
h = A("h")
a = B("a")
g = A("g")
j = B("j")
k = A("k")

b.x = j
b.z = j
i.x = c
i.v = h
c.x = j
c.v = b
h.x = c
h.z = a
a.x = j
a.v = b
g.x = c
g.z = i
j.x = a
j.v = b
k.x = i
k.z = i
assert a.v.z.x.txt == "a"