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

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

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

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

g = A("g")
c = B("c")
a = C("a")
k = D("k")
b = D("b")
i = D("i")
j = D("j")
m = B("m")
l = A("l")
d = C("d")

g.o = d
c.z = m
c.q = m
c.p = m
c.x = k
a.s = i
k.z = b
k.t = l
k.s = m
k.q = g
b.z = k
b.t = g
b.s = m
b.q = l
i.z = k
i.t = g
i.s = c
i.q = l
j.z = b
j.t = l
j.q = l
j.s = m
m.z = c
m.q = c
m.p = c
m.x = b
l.o = d
d.s = j
assert b.s.x.z.s.q.x.z.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

g = A("g")
c = B("c")
a = C("a")
k = D("k")
b = D("b")
i = D("i")
j = D("j")
m = B("m")
l = A("l")
d = C("d")

g.o = d
c.z = m
c.q = m
c.p = m
c.x = k
a.s = i
k.z = b
k.t = l
k.s = m
k.q = g
b.z = k
b.t = g
b.s = m
b.q = l
i.z = k
i.t = g
i.s = c
i.q = l
j.z = b
j.t = l
j.q = l
j.s = m
m.z = c
m.q = c
m.p = c
m.x = b
l.o = d
d.s = j
assert b.s.x.z.s.q.x.z.q.o.txt == "d"