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

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

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

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

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

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

n.u = g
n.r = g
b.w = k
b.y = f
a.z = g
k.w = b
k.u = a
k.x = a
f.z = n
f.x = a
g.w = k
g.y = f
assert a.z.y.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: B = None
        self.txt = txt

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

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

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

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

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

n.u = g
n.r = g
b.w = k
b.y = f
a.z = g
k.w = b
k.u = a
k.x = a
f.z = n
f.x = a
g.w = k
g.y = f
assert a.z.y.z.r.txt == "g"