class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: B = None
        self.v: A = None
        self.txt = txt

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

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

c = A("c")
j = B("j")
a = C("a")
l = B("l")
n = C("n")
d = B("d")
h = A("h")
g = B("g")
b = B("b")
f = B("f")

c.z = f
c.x = j
c.v = h
j.z = a
j.w = a
a.q = h
a.s = b
l.z = n
l.w = n
n.q = c
n.s = d
d.z = a
d.w = a
h.z = l
h.x = j
h.v = c
g.z = a
g.w = a
b.z = a
b.w = n
f.z = a
f.w = a
assert l.w.s.z.q.z.w.s.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: B = None
        self.v: A = None
        self.txt = txt

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

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

c = A("c")
j = B("j")
a = C("a")
l = B("l")
n = C("n")
d = B("d")
h = A("h")
g = B("g")
b = B("b")
f = B("f")

c.z = f
c.x = j
c.v = h
j.z = a
j.w = a
a.q = h
a.s = b
l.z = n
l.w = n
n.q = c
n.s = d
d.z = a
d.w = a
h.z = l
h.x = j
h.v = c
g.z = a
g.w = a
b.z = a
b.w = n
f.z = a
f.w = a
assert l.w.s.z.q.z.w.s.z.s.txt == "b"