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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.z: A = None
        self.w: B = None
        self.o: B = None
        self.y: C = None
        self.txt = txt

f = A("f")
g = B("g")
j = C("j")
n = D("n")
k = E("k")

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.z: A = None
        self.w: B = None
        self.o: B = None
        self.y: C = None
        self.txt = txt

f = A("f")
g = B("g")
j = C("j")
n = D("n")
k = E("k")

f.v = g
f.x = n
f.s = j
g.p = j
g.x = k
j.q = f
n.u = j
n.p = f
n.x = f
k.v = j
k.y = j
k.z = f
k.w = g
k.o = g
assert g.p.q.s.txt == "j"