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

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

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

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

a = A("a")
k = B("k")
j = C("j")
g = D("g")
c = D("c")
d = B("d")
h = D("h")
f = B("f")
n = D("n")

a.p = j
a.o = g
k.t = a
j.w = a
g.x = a
c.x = a
d.t = a
h.x = a
f.t = a
n.x = a
assert n.x.p.w.p.w.o.x.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.o: D = None
        self.txt = txt

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

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

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

a = A("a")
k = B("k")
j = C("j")
g = D("g")
c = D("c")
d = B("d")
h = D("h")
f = B("f")
n = D("n")

a.p = j
a.o = g
k.t = a
j.w = a
g.x = a
c.x = a
d.t = a
h.x = a
f.t = a
n.x = a
assert n.x.p.w.p.w.o.x.o.x.txt == "a"