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

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

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: A = None
        self.w: B = None
        self.txt = txt

i = A("i")
n = B("n")
f = C("f")

i.p = n
n.t = f
n.r = i
f.o = i
f.u = i
f.w = n
assert i.p.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: A = None
        self.w: B = None
        self.txt = txt

i = A("i")
n = B("n")
f = C("f")

i.p = n
n.t = f
n.r = i
f.o = i
f.u = i
f.w = n
assert i.p.r.p.txt == "n"