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

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

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

g = A("g")
m = B("m")
e = C("e")
n = A("n")
h = C("h")
k = B("k")
d = A("d")
l = B("l")

g.u = e
m.u = k
m.q = d
e.w = k
e.p = n
e.y = n
n.u = h
h.w = m
h.p = n
h.y = n
k.u = m
k.q = n
d.u = h
l.u = m
l.q = n
assert m.q.u.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

g = A("g")
m = B("m")
e = C("e")
n = A("n")
h = C("h")
k = B("k")
d = A("d")
l = B("l")

g.u = e
m.u = k
m.q = d
e.w = k
e.p = n
e.y = n
n.u = h
h.w = m
h.p = n
h.y = n
k.u = m
k.q = n
d.u = h
l.u = m
l.q = n
assert m.q.u.p.u.txt == "h"