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

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

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

m = A("m")
f = B("f")
l = C("l")
e = B("e")
d = A("d")
n = B("n")
j = A("j")
a = A("a")
g = A("g")

m.u = g
m.x = d
f.y = g
f.s = e
l.u = f
e.y = j
e.s = n
d.u = j
d.x = j
n.y = a
n.s = f
j.u = a
j.x = d
a.u = d
a.x = d
g.u = a
g.x = a
assert g.u.x.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.x: A = None
        self.txt = txt

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

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

m = A("m")
f = B("f")
l = C("l")
e = B("e")
d = A("d")
n = B("n")
j = A("j")
a = A("a")
g = A("g")

m.u = g
m.x = d
f.y = g
f.s = e
l.u = f
e.y = j
e.s = n
d.u = j
d.x = j
n.y = a
n.s = f
j.u = a
j.x = d
a.u = d
a.x = d
g.u = a
g.x = a
assert g.u.x.u.u.txt == "a"