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

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

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

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

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

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

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

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

f.t = l
d.y = n
d.p = n
d.t = m
n.r = m
m.y = i
m.p = i
m.t = d
i.r = m
c.r = m
l.t = f
a.r = m
assert i.r.y.r.t.y.r.t.t.txt == "m"