class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.y: A = None
        self.txt = txt

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

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

k.p = e
k.y = e
i.s = g
i.v = e
g.p = e
g.y = e
a.s = g
a.v = k
b.s = g
b.v = e
e.p = k
e.y = g
assert i.v.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.y: A = None
        self.txt = txt

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

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

k.p = e
k.y = e
i.s = g
i.v = e
g.p = e
g.y = e
a.s = g
a.v = k
b.s = g
b.v = e
e.p = k
e.y = g
assert i.v.y.y.txt == "e"