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

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: A = None
        self.u: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.t: F = None
        self.v: B = None
        self.txt = txt

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

f = A("f")
j = B("j")
e = C("e")
g = D("g")
l = E("l")
c = F("c")
a = A("a")
d = B("d")
m = E("m")
k = D("k")

f.z = g
j.o = a
e.y = j
e.p = f
g.p = d
g.q = f
g.u = l
l.x = k
l.t = c
l.v = j
c.z = k
a.z = g
d.o = f
m.x = g
m.t = c
m.v = j
k.p = j
k.q = f
k.u = m
assert a.z.p.o.z.q.z.p.o.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: A = None
        self.u: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.t: F = None
        self.v: B = None
        self.txt = txt

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

f = A("f")
j = B("j")
e = C("e")
g = D("g")
l = E("l")
c = F("c")
a = A("a")
d = B("d")
m = E("m")
k = D("k")

f.z = g
j.o = a
e.y = j
e.p = f
g.p = d
g.q = f
g.u = l
l.x = k
l.t = c
l.v = j
c.z = k
a.z = g
d.o = f
m.x = g
m.t = c
m.v = j
k.p = j
k.q = f
k.u = m
assert a.z.p.o.z.q.z.p.o.z.q.txt == "f"