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

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

c = A("c")
k = B("k")
e = B("e")
f = A("f")

c.s = e
k.v = f
k.p = f
e.v = c
e.p = c
f.s = k
assert f.s.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

c = A("c")
k = B("k")
e = B("e")
f = A("f")

c.s = e
k.v = f
k.p = f
e.v = c
e.p = c
f.s = k
assert f.s.v.s.txt == "k"