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

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

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

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

j.q = a
j.o = f
g.y = a
g.x = a
c.s = k
c.q = n
h.s = g
h.q = c
a.q = j
a.o = n
n.s = b
n.q = f
d.y = j
d.x = a
f.s = b
f.q = n
k.y = a
k.x = j
b.y = j
b.x = j
assert h.q.q.s.x.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.o: C = None
        self.txt = txt

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

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

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

j.q = a
j.o = f
g.y = a
g.x = a
c.s = k
c.q = n
h.s = g
h.q = c
a.q = j
a.o = n
n.s = b
n.q = f
d.y = j
d.x = a
f.s = b
f.q = n
k.y = a
k.x = j
b.y = j
b.x = j
assert h.q.q.s.x.q.q.q.txt == "a"