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

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

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

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

n.r = k
i.x = f
f.z = a
f.t = a
k.r = n
a.z = f
a.t = f
assert n.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

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

n.r = k
i.x = f
f.z = a
f.t = a
k.r = n
a.z = f
a.t = f
assert n.r.r.r.txt == "k"