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

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

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

l = A("l")
m = B("m")
g = C("g")
f = C("f")
k = C("k")
i = A("i")
a = A("a")
h = B("h")

l.y = f
l.r = i
l.z = m
m.p = i
m.w = f
g.x = k
g.o = k
g.r = l
f.x = k
f.o = k
f.r = i
k.x = g
k.o = g
k.r = l
i.y = k
i.r = a
i.z = h
a.y = g
a.r = l
a.z = h
h.p = l
h.w = g
assert a.y.r.y.r.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.r: A = None
        self.z: B = None
        self.txt = txt

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

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

l = A("l")
m = B("m")
g = C("g")
f = C("f")
k = C("k")
i = A("i")
a = A("a")
h = B("h")

l.y = f
l.r = i
l.z = m
m.p = i
m.w = f
g.x = k
g.o = k
g.r = l
f.x = k
f.o = k
f.r = i
k.x = g
k.o = g
k.r = l
i.y = k
i.r = a
i.z = h
a.y = g
a.r = l
a.z = h
h.p = l
h.w = g
assert a.y.r.y.r.z.p.txt == "l"