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

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

class C:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: D = None
        self.t: D = None
        self.y: C = None
        self.txt = txt

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

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

a.p = g
a.s = k
i.v = a
i.y = c
i.t = e
i.o = e
f.p = k
f.y = k
f.x = c
f.t = e
c.q = a
k.p = f
k.y = f
k.x = c
k.t = c
g.v = a
g.y = c
g.t = c
g.o = e
e.q = a
assert f.t.q.p.o.q.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: D = None
        self.t: D = None
        self.y: C = None
        self.txt = txt

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

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

a.p = g
a.s = k
i.v = a
i.y = c
i.t = e
i.o = e
f.p = k
f.y = k
f.x = c
f.t = e
c.q = a
k.p = f
k.y = f
k.x = c
k.t = c
g.v = a
g.y = c
g.t = c
g.o = e
e.q = a
assert f.t.q.p.o.q.p.o.txt == "e"