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

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

j.o = a
g.x = n
n.t = j
n.r = e
n.s = g
n.p = g
a.q = e
a.u = e
a.o = n
e.t = j
e.r = n
e.s = g
e.p = g
assert g.x.p.x.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

j.o = a
g.x = n
n.t = j
n.r = e
n.s = g
n.p = g
a.q = e
a.u = e
a.o = n
e.t = j
e.r = n
e.s = g
e.p = g
assert g.x.p.x.t.o.txt == "a"