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

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

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

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

f.q = m
h.p = n
h.q = m
h.y = i
i.z = f
i.u = f
n.p = d
n.q = b
n.y = i
b.p = n
b.q = h
b.y = i
d.p = h
d.q = m
d.y = i
m.p = h
m.q = h
m.y = i
assert d.p.y.z.q.y.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

f.q = m
h.p = n
h.q = m
h.y = i
i.z = f
i.u = f
n.p = d
n.q = b
n.y = i
b.p = n
b.q = h
b.y = i
d.p = h
d.q = m
d.y = i
m.p = h
m.q = h
m.y = i
assert d.p.y.z.q.y.u.q.txt == "m"