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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.x: B = None
        self.s: D = None
        self.txt = txt

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

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

h = A("h")
f = B("f")
j = C("j")
e = D("e")
m = A("m")
i = A("i")
b = C("b")
n = B("n")

h.p = e
f.q = e
f.s = e
f.x = n
j.u = b
j.s = b
j.q = m
e.x = j
e.r = f
m.p = e
i.p = e
b.u = j
b.s = j
b.q = h
n.q = e
n.s = e
n.x = f
assert i.p.x.u.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.x: B = None
        self.s: D = None
        self.txt = txt

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

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

h = A("h")
f = B("f")
j = C("j")
e = D("e")
m = A("m")
i = A("i")
b = C("b")
n = B("n")

h.p = e
f.q = e
f.s = e
f.x = n
j.u = b
j.s = b
j.q = m
e.x = j
e.r = f
m.p = e
i.p = e
b.u = j
b.s = j
b.q = h
n.q = e
n.s = e
n.x = f
assert i.p.x.u.q.p.txt == "e"