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

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

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

g = A("g")
i = B("i")
n = C("n")
c = C("c")
f = C("f")
e = C("e")
l = A("l")
m = A("m")
h = B("h")
d = C("d")

g.x = n
g.y = f
i.p = m
i.s = m
n.u = i
c.u = i
f.u = i
e.u = h
l.x = d
l.y = n
m.x = e
m.y = d
h.p = m
h.s = l
d.u = i
assert d.u.s.x.u.s.x.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: C = None
        self.txt = txt

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

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

g = A("g")
i = B("i")
n = C("n")
c = C("c")
f = C("f")
e = C("e")
l = A("l")
m = A("m")
h = B("h")
d = C("d")

g.x = n
g.y = f
i.p = m
i.s = m
n.u = i
c.u = i
f.u = i
e.u = h
l.x = d
l.y = n
m.x = e
m.y = d
h.p = m
h.s = l
d.u = i
assert d.u.s.x.u.s.x.u.p.txt == "m"