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

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

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

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

d = A("d")
n = B("n")
c = C("c")
h = D("h")
f = D("f")
a = D("a")
i = B("i")

d.q = n
d.s = n
n.q = h
n.u = h
n.x = c
c.x = d
c.o = d
h.q = n
h.t = n
h.v = f
h.o = d
f.q = i
f.v = a
f.o = d
f.t = n
a.q = i
a.t = i
a.v = h
a.o = d
i.q = a
i.u = h
i.x = c
assert c.x.q.u.o.s.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: B = None
        self.txt = txt

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

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

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

d = A("d")
n = B("n")
c = C("c")
h = D("h")
f = D("f")
a = D("a")
i = B("i")

d.q = n
d.s = n
n.q = h
n.u = h
n.x = c
c.x = d
c.o = d
h.q = n
h.t = n
h.v = f
h.o = d
f.q = i
f.v = a
f.o = d
f.t = n
a.q = i
a.t = i
a.v = h
a.o = d
i.q = a
i.u = h
i.x = c
assert c.x.q.u.o.s.x.o.txt == "d"