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

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: D = None
        self.p: B = None
        self.t: B = None
        self.x: A = None
        self.txt = txt

a = A("a")
b = B("b")
g = C("g")
m = D("m")
n = E("n")
e = D("e")
k = B("k")

a.x = b
a.v = g
b.p = g
g.y = b
g.w = n
m.z = k
n.w = m
n.p = b
n.t = k
n.x = a
e.z = b
k.p = g
assert n.w.z.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.v: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: D = None
        self.p: B = None
        self.t: B = None
        self.x: A = None
        self.txt = txt

a = A("a")
b = B("b")
g = C("g")
m = D("m")
n = E("n")
e = D("e")
k = B("k")

a.x = b
a.v = g
b.p = g
g.y = b
g.w = n
m.z = k
n.w = m
n.p = b
n.t = k
n.x = a
e.z = b
k.p = g
assert n.w.z.p.y.txt == "b"