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

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

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

m = A("m")
j = B("j")
b = C("b")
f = B("f")
e = B("e")
d = B("d")
i = A("i")
g = A("g")
h = B("h")
l = C("l")

m.x = g
m.p = g
m.u = b
j.y = d
j.t = h
j.w = f
b.z = l
f.y = e
f.t = d
f.w = j
e.y = j
e.w = j
e.t = h
d.y = f
d.t = f
d.w = j
i.x = m
i.p = m
i.u = l
g.x = m
g.p = i
g.u = b
h.y = f
h.t = j
h.w = j
l.z = b
assert d.w.y.t.w.y.w.y.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: A = None
        self.u: C = None
        self.txt = txt

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

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

m = A("m")
j = B("j")
b = C("b")
f = B("f")
e = B("e")
d = B("d")
i = A("i")
g = A("g")
h = B("h")
l = C("l")

m.x = g
m.p = g
m.u = b
j.y = d
j.t = h
j.w = f
b.z = l
f.y = e
f.t = d
f.w = j
e.y = j
e.w = j
e.t = h
d.y = f
d.t = f
d.w = j
i.x = m
i.p = m
i.u = l
g.x = m
g.p = i
g.u = b
h.y = f
h.t = j
h.w = j
l.z = b
assert d.w.y.t.w.y.w.y.t.t.txt == "d"