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

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

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

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

l = A("l")
j = B("j")
m = C("m")
n = D("n")
h = C("h")
g = B("g")
d = D("d")
a = C("a")

l.r = a
l.v = m
j.v = g
m.p = l
m.y = l
m.u = l
m.z = n
n.t = d
n.s = h
n.x = m
h.p = l
h.y = l
h.u = l
h.z = n
g.v = j
d.t = n
d.s = m
d.x = m
a.p = l
a.y = l
a.u = l
a.z = n
assert j.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.v: C = None
        self.txt = txt

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

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

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

l = A("l")
j = B("j")
m = C("m")
n = D("n")
h = C("h")
g = B("g")
d = D("d")
a = C("a")

l.r = a
l.v = m
j.v = g
m.p = l
m.y = l
m.u = l
m.z = n
n.t = d
n.s = h
n.x = m
h.p = l
h.y = l
h.u = l
h.z = n
g.v = j
d.t = n
d.s = m
d.x = m
a.p = l
a.y = l
a.u = l
a.z = n
assert j.v.v.v.v.v.txt == "g"