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

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

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

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

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

d = A("d")
g = B("g")
m = C("m")
a = D("a")
n = E("n")
j = C("j")
e = B("e")
b = B("b")
i = E("i")
h = C("h")

d.p = g
g.q = d
g.u = d
g.x = a
m.y = e
a.t = j
a.u = j
a.q = i
a.x = i
n.q = a
n.z = a
j.y = e
e.q = d
e.u = d
e.x = a
b.q = d
b.u = d
b.x = a
i.q = a
i.z = a
h.y = g
assert j.y.x.x.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

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

d = A("d")
g = B("g")
m = C("m")
a = D("a")
n = E("n")
j = C("j")
e = B("e")
b = B("b")
i = E("i")
h = C("h")

d.p = g
g.q = d
g.u = d
g.x = a
m.y = e
a.t = j
a.u = j
a.q = i
a.x = i
n.q = a
n.z = a
j.y = e
e.q = d
e.u = d
e.x = a
b.q = d
b.u = d
b.x = a
i.q = a
i.z = a
h.y = g
assert j.y.x.x.z.t.txt == "j"