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

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

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

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

f.y = b
m.s = b
n.r = h
n.x = h
n.u = h
b.y = f
a.y = f
h.r = n
h.x = n
h.u = n
assert m.s.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

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

f.y = b
m.s = b
n.r = h
n.x = h
n.u = h
b.y = f
a.y = f
h.r = n
h.x = n
h.u = n
assert m.s.y.y.txt == "b"