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

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: A = None
        self.y: C = None
        self.txt = txt

j = A("j")
g = B("g")
n = C("n")
b = D("b")
i = B("i")
a = C("a")
f = B("f")
k = A("k")

j.o = i
j.x = i
j.p = g
g.q = i
g.p = f
g.r = f
g.s = b
n.z = b
n.s = j
b.p = i
b.z = j
b.y = a
i.q = f
i.p = f
i.r = g
i.s = b
a.z = b
a.s = k
f.q = g
f.p = g
f.r = g
f.s = b
k.o = i
k.p = f
k.x = g
assert g.q.s.p.q.r.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: B = None
        self.x: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: A = None
        self.y: C = None
        self.txt = txt

j = A("j")
g = B("g")
n = C("n")
b = D("b")
i = B("i")
a = C("a")
f = B("f")
k = A("k")

j.o = i
j.x = i
j.p = g
g.q = i
g.p = f
g.r = f
g.s = b
n.z = b
n.s = j
b.p = i
b.z = j
b.y = a
i.q = f
i.p = f
i.r = g
i.s = b
a.z = b
a.s = k
f.q = g
f.p = g
f.r = g
f.s = b
k.o = i
k.p = f
k.x = g
assert g.q.s.p.q.r.p.s.txt == "b"