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

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

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

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

b = A("b")
f = B("f")
a = C("a")
i = D("i")
n = C("n")
e = A("e")
m = D("m")
k = C("k")
l = D("l")

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

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

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

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

b = A("b")
f = B("f")
a = C("a")
i = D("i")
n = C("n")
e = A("e")
m = D("m")
k = C("k")
l = D("l")

b.r = n
b.y = e
b.x = f
f.w = e
a.x = b
a.z = f
a.u = f
a.v = m
i.z = b
i.y = b
i.w = f
i.r = m
n.x = b
n.z = f
n.u = f
n.v = l
e.r = n
e.y = b
e.x = f
m.z = b
m.y = b
m.w = f
m.r = l
k.x = e
k.z = f
k.u = f
k.v = m
l.z = e
l.y = e
l.w = f
l.r = m
assert n.x.x.w.r.v.r.w.txt == "f"