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

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

g = A("g")
j = B("j")
c = A("c")
l = B("l")
m = A("m")
f = B("f")
e = A("e")
k = A("k")
b = B("b")

g.v = f
g.z = l
j.u = k
j.x = b
c.v = j
c.z = l
l.u = g
l.x = j
m.v = b
m.z = j
f.u = m
f.x = j
e.v = j
e.z = b
k.v = f
k.z = l
b.u = m
b.x = f
assert k.v.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: B = None
        self.txt = txt

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

g = A("g")
j = B("j")
c = A("c")
l = B("l")
m = A("m")
f = B("f")
e = A("e")
k = A("k")
b = B("b")

g.v = f
g.z = l
j.u = k
j.x = b
c.v = j
c.z = l
l.u = g
l.x = j
m.v = b
m.z = j
f.u = m
f.x = j
e.v = j
e.z = b
k.v = f
k.z = l
b.u = m
b.x = f
assert k.v.x.u.txt == "k"