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

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: D = None
        self.o: D = None
        self.txt = txt

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

n = A("n")
l = B("l")
m = C("m")
f = D("f")
i = B("i")
g = C("g")
c = B("c")

n.v = c
n.q = m
n.r = m
n.u = f
l.y = f
m.v = n
m.w = f
m.o = f
f.t = n
f.r = m
i.y = f
g.v = n
g.w = f
g.o = f
c.y = f
assert l.y.r.v.u.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: C = None
        self.r: C = None
        self.u: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: D = None
        self.o: D = None
        self.txt = txt

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

n = A("n")
l = B("l")
m = C("m")
f = D("f")
i = B("i")
g = C("g")
c = B("c")

n.v = c
n.q = m
n.r = m
n.u = f
l.y = f
m.v = n
m.w = f
m.o = f
f.t = n
f.r = m
i.y = f
g.v = n
g.w = f
g.o = f
c.y = f
assert l.y.r.v.u.r.v.txt == "n"