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

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

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

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

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

a.o = g
k.q = e
k.p = e
k.z = j
j.w = n
n.y = e
n.q = f
n.v = a
n.t = a
e.q = k
e.p = k
e.z = i
f.y = e
f.q = n
f.v = g
f.t = a
g.o = a
i.w = n
assert k.q.q.z.w.v.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

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

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

a.o = g
k.q = e
k.p = e
k.z = j
j.w = n
n.y = e
n.q = f
n.v = a
n.t = a
e.q = k
e.p = k
e.z = i
f.y = e
f.q = n
f.v = g
f.t = a
g.o = a
i.w = n
assert k.q.q.z.w.v.o.o.o.txt == "g"