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

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

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

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

l = A("l")
i = B("i")
h = C("h")
d = D("d")
a = D("a")
f = C("f")
n = D("n")
b = B("b")
m = A("m")

l.y = n
l.v = i
l.u = b
l.s = h
i.v = b
i.w = m
i.u = f
i.o = d
h.q = d
h.p = b
h.x = a
d.r = a
a.r = d
f.q = a
f.p = i
f.x = d
n.r = d
b.v = i
b.w = l
b.u = h
b.o = a
m.y = d
m.v = i
m.u = b
m.s = h
assert b.v.o.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.v: B = None
        self.u: B = None
        self.s: C = None
        self.txt = txt

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

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

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

l = A("l")
i = B("i")
h = C("h")
d = D("d")
a = D("a")
f = C("f")
n = D("n")
b = B("b")
m = A("m")

l.y = n
l.v = i
l.u = b
l.s = h
i.v = b
i.w = m
i.u = f
i.o = d
h.q = d
h.p = b
h.x = a
d.r = a
a.r = d
f.q = a
f.p = i
f.x = d
n.r = d
b.v = i
b.w = l
b.u = h
b.o = a
m.y = d
m.v = i
m.u = b
m.s = h
assert b.v.o.r.r.txt == "d"