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

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

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

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

g.r = f
g.p = f
g.s = k
f.p = k
k.t = g
assert k.t.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.p: B = None
        self.s: C = None
        self.txt = txt

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

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

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

g.r = f
g.p = f
g.s = k
f.p = k
k.t = g
assert k.t.p.p.txt == "k"