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

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

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

f = A("f")
l = B("l")
d = C("d")
k = C("k")
h = A("h")
g = B("g")
c = A("c")
a = C("a")
n = B("n")
i = A("i")

f.w = c
f.t = d
l.u = d
l.o = i
l.q = f
d.z = f
d.r = a
k.z = f
k.r = d
h.w = i
h.t = d
g.u = k
g.o = h
g.q = i
c.w = h
c.t = a
a.z = c
a.r = d
n.u = a
n.o = f
n.q = h
i.w = h
i.t = d
assert g.o.t.z.t.r.r.r.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.t: C = None
        self.txt = txt

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

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

f = A("f")
l = B("l")
d = C("d")
k = C("k")
h = A("h")
g = B("g")
c = A("c")
a = C("a")
n = B("n")
i = A("i")

f.w = c
f.t = d
l.u = d
l.o = i
l.q = f
d.z = f
d.r = a
k.z = f
k.r = d
h.w = i
h.t = d
g.u = k
g.o = h
g.q = i
c.w = h
c.t = a
a.z = c
a.r = d
n.u = a
n.o = f
n.q = h
i.w = h
i.t = d
assert g.o.t.z.t.r.r.r.r.z.txt == "f"