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

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

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

h = A("h")
k = B("k")
f = C("f")

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

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

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

h = A("h")
k = B("k")
f = C("f")

h.y = k
h.q = k
h.s = k
k.p = f
k.v = f
f.y = h
assert k.p.y.y.txt == "k"