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

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

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

n = A("n")
e = B("e")
h = C("h")

n.v = h
e.s = n
e.x = h
h.s = n
assert h.s.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

n = A("n")
e = B("e")
h = C("h")

n.v = h
e.s = n
e.x = h
h.s = n
assert h.s.v.s.txt == "n"