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

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

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

i = A("i")
n = B("n")
c = C("c")
g = C("g")
m = A("m")
a = B("a")
f = A("f")

i.t = n
i.y = a
n.r = a
c.s = a
g.s = a
m.t = a
m.y = a
a.r = n
f.t = a
f.y = a
assert a.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.y: B = None
        self.txt = txt

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

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

i = A("i")
n = B("n")
c = C("c")
g = C("g")
m = A("m")
a = B("a")
f = A("f")

i.t = n
i.y = a
n.r = a
c.s = a
g.s = a
m.t = a
m.y = a
a.r = n
f.t = a
f.y = a
assert a.r.r.r.r.r.txt == "n"