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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.p: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: E = None
        self.txt = txt

d = A("d")
g = B("g")
h = C("h")
f = D("f")
j = E("j")
e = F("e")
n = G("n")
c = E("c")

d.x = g
g.p = f
h.z = f
h.u = g
f.u = j
j.x = e
j.q = e
j.t = f
j.z = f
j.w = c
e.p = n
n.r = d
n.u = j
c.x = e
c.q = e
c.t = f
c.z = f
c.w = j
assert d.x.p.u.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.p: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: E = None
        self.txt = txt

d = A("d")
g = B("g")
h = C("h")
f = D("f")
j = E("j")
e = F("e")
n = G("n")
c = E("c")

d.x = g
g.p = f
h.z = f
h.u = g
f.u = j
j.x = e
j.q = e
j.t = f
j.z = f
j.w = c
e.p = n
n.r = d
n.u = j
c.x = e
c.q = e
c.t = f
c.z = f
c.w = j
assert d.x.p.u.z.u.txt == "j"