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

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

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

d = A("d")
b = B("b")
a = C("a")
g = C("g")
j = C("j")
k = B("k")
m = B("m")
h = B("h")
e = A("e")

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

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

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

d = A("d")
b = B("b")
a = C("a")
g = C("g")
j = C("j")
k = B("k")
m = B("m")
h = B("h")
e = A("e")

d.q = e
b.s = h
b.o = a
b.x = k
a.o = e
a.y = d
g.o = e
g.y = e
j.o = d
j.y = e
k.s = m
k.o = j
k.x = b
m.s = h
m.x = h
m.o = j
h.s = b
h.o = g
h.x = m
e.q = d
assert e.q.q.q.q.q.txt == "d"