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

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

n = A("n")
a = B("a")
g = B("g")
k = A("k")
j = B("j")

n.s = g
n.z = j
a.v = k
g.v = k
k.s = j
k.z = a
j.v = k
assert a.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: B = None
        self.txt = txt

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

n = A("n")
a = B("a")
g = B("g")
k = A("k")
j = B("j")

n.s = g
n.z = j
a.v = k
g.v = k
k.s = j
k.z = a
j.v = k
assert a.v.s.v.txt == "k"