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

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

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

f = A("f")
l = B("l")
i = C("i")
n = B("n")
b = B("b")
h = A("h")
m = C("m")

f.s = i
f.t = h
f.v = h
l.r = h
l.p = h
l.y = i
i.s = m
i.t = l
n.r = h
n.y = m
n.p = f
b.r = f
b.p = f
b.y = m
h.s = m
h.t = f
h.v = f
m.s = i
m.t = l
assert n.r.s.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: A = None
        self.v: A = None
        self.txt = txt

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

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

f = A("f")
l = B("l")
i = C("i")
n = B("n")
b = B("b")
h = A("h")
m = C("m")

f.s = i
f.t = h
f.v = h
l.r = h
l.p = h
l.y = i
i.s = m
i.t = l
n.r = h
n.y = m
n.p = f
b.r = f
b.p = f
b.y = m
h.s = m
h.t = f
h.v = f
m.s = i
m.t = l
assert n.r.s.t.p.txt == "h"