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

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

i = A("i")
g = B("g")
h = A("h")
a = A("a")
k = B("k")
e = B("e")
b = A("b")
n = A("n")

i.v = g
i.s = h
g.x = a
g.r = k
h.v = k
h.s = i
a.v = g
a.s = h
k.x = n
k.r = e
e.x = n
e.r = k
b.v = g
b.s = n
n.v = g
n.s = a
assert k.x.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.s: A = None
        self.txt = txt

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

i = A("i")
g = B("g")
h = A("h")
a = A("a")
k = B("k")
e = B("e")
b = A("b")
n = A("n")

i.v = g
i.s = h
g.x = a
g.r = k
h.v = k
h.s = i
a.v = g
a.s = h
k.x = n
k.r = e
e.x = n
e.r = k
b.v = g
b.s = n
n.v = g
n.s = a
assert k.x.s.v.txt == "g"