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

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

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

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

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

f.o = h
n.u = h
n.x = h
n.w = a
g.z = l
g.w = a
g.r = a
g.s = f
h.q = d
h.u = f
i.z = l
i.w = a
i.r = a
i.s = c
l.z = g
l.w = n
l.r = n
l.s = c
a.u = d
a.w = n
a.x = h
d.q = h
d.u = c
c.o = h
assert f.o.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

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

f.o = h
n.u = h
n.x = h
n.w = a
g.z = l
g.w = a
g.r = a
g.s = f
h.q = d
h.u = f
i.z = l
i.w = a
i.r = a
i.s = c
l.z = g
l.w = n
l.r = n
l.s = c
a.u = d
a.w = n
a.x = h
d.q = h
d.u = c
c.o = h
assert f.o.q.q.q.txt == "d"