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

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

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

g = A("g")
i = B("i")
n = C("n")
d = C("d")
l = A("l")
h = A("h")
m = C("m")
f = B("f")
c = B("c")
b = C("b")

g.z = h
g.y = f
i.q = d
n.s = d
d.s = n
l.z = h
l.y = f
h.z = l
h.y = f
m.s = d
f.q = n
c.q = n
b.s = m
assert i.q.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.y: B = None
        self.txt = txt

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

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

g = A("g")
i = B("i")
n = C("n")
d = C("d")
l = A("l")
h = A("h")
m = C("m")
f = B("f")
c = B("c")
b = C("b")

g.z = h
g.y = f
i.q = d
n.s = d
d.s = n
l.z = h
l.y = f
h.z = l
h.y = f
m.s = d
f.q = n
c.q = n
b.s = m
assert i.q.s.s.s.s.s.s.txt == "d"