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

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

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

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

g = A("g")
b = B("b")
f = C("f")
i = D("i")
m = D("m")
h = C("h")
e = D("e")
a = C("a")
l = A("l")
c = B("c")

g.v = e
g.r = l
b.w = g
b.s = c
f.y = g
f.z = h
i.t = f
i.x = b
i.s = a
i.w = l
m.t = a
m.x = c
m.s = f
m.w = g
h.y = l
h.z = a
e.t = f
e.x = b
e.s = h
e.w = l
a.y = g
a.z = f
l.v = e
l.r = g
c.w = l
c.s = b
assert c.w.r.r.v.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.r: A = None
        self.txt = txt

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

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

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

g = A("g")
b = B("b")
f = C("f")
i = D("i")
m = D("m")
h = C("h")
e = D("e")
a = C("a")
l = A("l")
c = B("c")

g.v = e
g.r = l
b.w = g
b.s = c
f.y = g
f.z = h
i.t = f
i.x = b
i.s = a
i.w = l
m.t = a
m.x = c
m.s = f
m.w = g
h.y = l
h.z = a
e.t = f
e.x = b
e.s = h
e.w = l
a.y = g
a.z = f
l.v = e
l.r = g
c.w = l
c.s = b
assert c.w.r.r.v.w.v.txt == "e"