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

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

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

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

j = A("j")
b = B("b")
e = C("e")
m = D("m")
a = C("a")
h = D("h")
c = B("c")

j.x = e
b.u = j
b.p = c
e.o = j
e.p = a
m.s = j
m.x = e
m.t = e
a.o = j
a.p = e
h.s = j
h.x = a
h.t = a
c.u = j
c.p = b
assert c.u.x.o.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

j = A("j")
b = B("b")
e = C("e")
m = D("m")
a = C("a")
h = D("h")
c = B("c")

j.x = e
b.u = j
b.p = c
e.o = j
e.p = a
m.s = j
m.x = e
m.t = e
a.o = j
a.p = e
h.s = j
h.x = a
h.t = a
c.u = j
c.p = b
assert c.u.x.o.x.p.txt == "a"