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

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

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

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

g = A("g")
i = B("i")
b = C("b")
j = D("j")
n = D("n")
m = D("m")
k = D("k")
l = A("l")
h = B("h")

g.v = k
g.r = l
g.s = l
g.x = l
i.u = l
i.z = h
i.s = k
b.o = h
b.x = h
b.s = i
b.r = g
j.x = b
j.q = g
j.v = h
n.x = b
n.q = g
n.v = h
m.x = b
m.q = l
m.v = h
k.x = b
k.q = g
k.v = h
l.v = j
l.r = g
l.s = g
l.x = g
h.u = l
h.z = i
h.s = n
assert l.v.v.s.v.u.r.s.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.r: A = None
        self.s: A = None
        self.x: A = None
        self.txt = txt

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

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

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

g = A("g")
i = B("i")
b = C("b")
j = D("j")
n = D("n")
m = D("m")
k = D("k")
l = A("l")
h = B("h")

g.v = k
g.r = l
g.s = l
g.x = l
i.u = l
i.z = h
i.s = k
b.o = h
b.x = h
b.s = i
b.r = g
j.x = b
j.q = g
j.v = h
n.x = b
n.q = g
n.v = h
m.x = b
m.q = l
m.v = h
k.x = b
k.q = g
k.v = h
l.v = j
l.r = g
l.s = g
l.x = g
h.u = l
h.z = i
h.s = n
assert l.v.v.s.v.u.r.s.v.q.txt == "g"