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

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

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

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

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

c.x = j
c.s = n
n.z = a
n.q = a
n.w = j
j.p = n
j.u = n
j.x = n
j.y = a
a.s = j
a.r = g
a.p = g
g.x = j
g.s = n
f.x = j
f.s = n
assert f.s.w.y.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.s: B = None
        self.txt = txt

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

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

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

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

c.x = j
c.s = n
n.z = a
n.q = a
n.w = j
j.p = n
j.u = n
j.x = n
j.y = a
a.s = j
a.r = g
a.p = g
g.x = j
g.s = n
f.x = j
f.s = n
assert f.s.w.y.r.x.txt == "j"